release/src/linux/linux/arch/arm/nwfpe/softfloat.c
/*
-------------------------------------------------------------------------------
Returns the result of converting the 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 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 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 float64_to_int32_round_to_zero( float64 a )
{
    flag aSign;
    int16 aExp, shiftCount;
    bits64 aSig, savedASig;
    int32 z;
    aSig = extractFloat64Frac( a );
    aExp = extractFloat64Exp( a );
    aSign = extractFloat64Sign( a );
    shiftCount = 0x433 - aExp;
    if ( shiftCount < 21 ) {
        if ( ( aExp == 0x7FF ) && aSig ) aSign = 0;
        goto invalid;
    }
    else if ( 52 < shiftCount ) {
        if ( aExp || aSig ) float_exception_flags |= float_flag_inexact;
        return 0;
    }
    aSig |= LIT64( 0x0010000000000000 );
    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 float64_to_int32_round_to_zero ( float64 a ) { flag aSign ; int16 aExp , shiftCount ; bits64 aSig , savedASig ; int32 z ; aSig = extractFloat64Frac ( a ) ; aExp = extractFloat64Exp ( a ) ; aSign = extractFloat64Sign ( a ) ; shiftCount = 0x433 - aExp ; if ( shiftCount < 21 ) { if ( ( aExp == 0x7FF ) && aSig ) aSign = 0 ; goto invalid ; } else if ( 52 < shiftCount ) { if ( aExp || aSig ) float_exception_flags |= float_flag_inexact ; return 0 ; } aSig |= LIT64 ( 0x0010000000000000 ) ; 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 double-precision floating-point value
`a' to the 32-bit two's complement integer format.
Returns the result of converting the double - precision floating - point value ` a ' to the 32 - bit two ' s complement integer format .