release/src/linux/linux/arch/arm/nwfpe/softfloat.c
/*
-------------------------------------------------------------------------------
Returns the result of converting the extended double-precision floating-
point value `a' to the 32-bit two's complement integer format.  The
conversion is performed according to the IEC/IEEE Standard for Binary
Floating-point Arithmetic, except that the conversion is always rounded
toward zero.  If `a' is a NaN, the largest positive integer is returned.
Otherwise, if the conversion overflows, the largest integer with the same
sign as `a' is returned.
-------------------------------------------------------------------------------
*/
Returns the result of converting the extended double-precision floating
point value `a' to the 32-bit two's complement integer format.  The
conversion is performed according to the IEC/IEEE Standard for Binary
Floating-point Arithmetic, except that the conversion is always rounded
toward zero.  If `a' is a NaN, the largest positive integer is returned.
Otherwise, if the conversion overflows, the largest integer with the same
sign as `a' is returned.
Returns the result of converting the extended double - precision floating point value ` a ' to the 32 - bit two ' s complement integer format . The conversion is performed according to the IEC / IEEE Standard for Binary Floating - point Arithmetic except that the conversion is always rounded toward zero . If ` a ' is a NaN the largest positive integer is returned . Otherwise if the conversion overflows the largest integer with the same sign as ` a ' is returned .
int32 floatx80_to_int32_round_to_zero( floatx80 a )
{
    flag aSign;
    int32 aExp, shiftCount;
    bits64 aSig, savedASig;
    int32 z;
    aSig = extractFloatx80Frac( a );
    aExp = extractFloatx80Exp( a );
    aSign = extractFloatx80Sign( a );
    shiftCount = 0x403E - aExp;
    if ( shiftCount < 32 ) {
        if ( ( aExp == 0x7FFF ) && (bits64) ( aSig<<1 ) ) aSign = 0;
        goto invalid;
    }
    else if ( 63 < shiftCount ) {
        if ( aExp || aSig ) float_exception_flags |= float_flag_inexact;
        return 0;
    }
    savedASig = aSig;
    aSig >>= shiftCount;
    z = aSig;
    if ( aSign ) z = - z;
    if ( ( z < 0 ) ^ aSign ) {
 invalid:
        float_exception_flags |= float_flag_invalid;
        return aSign ? 0x80000000 : 0x7FFFFFFF;
    }
    if ( ( aSig<<shiftCount ) != savedASig ) {
        float_exception_flags |= float_flag_inexact;
    }
    return z;
}
int32 floatx80_to_int32_round_to_zero ( floatx80 a ) { flag aSign ; int32 aExp , shiftCount ; bits64 aSig , savedASig ; int32 z ; aSig = extractFloatx80Frac ( a ) ; aExp = extractFloatx80Exp ( a ) ; aSign = extractFloatx80Sign ( a ) ; shiftCount = 0x403E - aExp ; if ( shiftCount < 32 ) { if ( ( aExp == 0x7FFF ) && ( bits64 ) ( aSig << 1 ) ) aSign = 0 ; goto invalid ; } else if ( 63 < shiftCount ) { if ( aExp || aSig ) float_exception_flags |= float_flag_inexact ; return 0 ; } savedASig = aSig ; aSig >>= shiftCount ; z = aSig ; if ( aSign ) z = - z ; if ( ( z < 0 ) ^ aSign ) { invalid : float_exception_flags |= float_flag_invalid ; return aSign ? 0x80000000 : 0x7FFFFFFF ; } if ( ( aSig << shiftCount ) != savedASig ) { float_exception_flags |= float_flag_inexact ; } return z ; }
Returns the result of converting the extended double-precision floating
point value `a' to the 32-bit two's complement integer format.
Returns the result of converting the extended double - precision floating point value ` a ' to the 32 - bit two ' s complement integer format .