release/src/linux/linux/arch/arm/nwfpe/softfloat.c
/*
-------------------------------------------------------------------------------
Rounds the extended double-precision floating-point value `a' to an integer,
and returns the result as an extended quadruple-precision floating-point
value.  The operation is performed according to the IEC/IEEE Standard for
Binary Floating-point Arithmetic.
-------------------------------------------------------------------------------
*/
Rounds the extended double-precision floating-point value `a' to an integer,
and returns the result as an extended quadruple-precision floating-point
value.  The operation is performed according to the IEC/IEEE Standard for
Binary Floating-point Arithmetic.
Rounds the extended double - precision floating - point value ` a ' to an integer and returns the result as an extended quadruple - precision floating - point value . The operation is performed according to the IEC / IEEE Standard for Binary Floating - point Arithmetic .
floatx80 floatx80_round_to_int( floatx80 a )
{
    flag aSign;
    int32 aExp;
    bits64 lastBitMask, roundBitsMask;
    int8 roundingMode;
    floatx80 z;
    aExp = extractFloatx80Exp( a );
    if ( 0x403E <= aExp ) {
        if ( ( aExp == 0x7FFF ) && (bits64) ( extractFloatx80Frac( a )<<1 ) ) {
            return propagateFloatx80NaN( a, a );
        }
        return a;
    }
    if ( aExp <= 0x3FFE ) {
        if (    ( aExp == 0 )
             && ( (bits64) ( extractFloatx80Frac( a )<<1 ) == 0 ) ) {
            return a;
        }
        float_exception_flags |= float_flag_inexact;
        aSign = extractFloatx80Sign( a );
        switch ( float_rounding_mode ) {
         case float_round_nearest_even:
            if ( ( aExp == 0x3FFE ) && (bits64) ( extractFloatx80Frac( a )<<1 )
               ) {
                return
                    packFloatx80( aSign, 0x3FFF, LIT64( 0x8000000000000000 ) );
            }
            break;
         case float_round_down:
            return
                  aSign ?
                      packFloatx80( 1, 0x3FFF, LIT64( 0x8000000000000000 ) )
                : packFloatx80( 0, 0, 0 );
         case float_round_up:
            return
                  aSign ? packFloatx80( 1, 0, 0 )
                : packFloatx80( 0, 0x3FFF, LIT64( 0x8000000000000000 ) );
        }
        return packFloatx80( aSign, 0, 0 );
    }
    lastBitMask = 1;
    lastBitMask <<= 0x403E - aExp;
    roundBitsMask = lastBitMask - 1;
    z = a;
    roundingMode = float_rounding_mode;
    if ( roundingMode == float_round_nearest_even ) {
        z.low += lastBitMask>>1;
        if ( ( z.low & roundBitsMask ) == 0 ) z.low &= ~ lastBitMask;
    }
    else if ( roundingMode != float_round_to_zero ) {
        if ( extractFloatx80Sign( z ) ^ ( roundingMode == float_round_up ) ) {
            z.low += roundBitsMask;
        }
    }
    z.low &= ~ roundBitsMask;
    if ( z.low == 0 ) {
        ++z.high;
        z.low = LIT64( 0x8000000000000000 );
    }
    if ( z.low != a.low ) float_exception_flags |= float_flag_inexact;
    return z;
}
floatx80 floatx80_round_to_int ( floatx80 a ) { flag aSign ; int32 aExp ; bits64 lastBitMask , roundBitsMask ; int8 roundingMode ; floatx80 z ; aExp = extractFloatx80Exp ( a ) ; if ( 0x403E <= aExp ) { if ( ( aExp == 0x7FFF ) && ( bits64 ) ( extractFloatx80Frac ( a ) << 1 ) ) { return propagateFloatx80NaN ( a , a ) ; } return a ; } if ( aExp <= 0x3FFE ) { if ( ( aExp == 0 ) && ( ( bits64 ) ( extractFloatx80Frac ( a ) << 1 ) == 0 ) ) { return a ; } float_exception_flags |= float_flag_inexact ; aSign = extractFloatx80Sign ( a ) ; switch ( float_rounding_mode ) { case float_round_nearest_even : if ( ( aExp == 0x3FFE ) && ( bits64 ) ( extractFloatx80Frac ( a ) << 1 ) ) { return packFloatx80 ( aSign , 0x3FFF , LIT64 ( 0x8000000000000000 ) ) ; } break ; case float_round_down : return aSign ? packFloatx80 ( 1 , 0x3FFF , LIT64 ( 0x8000000000000000 ) ) : packFloatx80 ( 0 , 0 , 0 ) ; case float_round_up : return aSign ? packFloatx80 ( 1 , 0 , 0 ) : packFloatx80 ( 0 , 0x3FFF , LIT64 ( 0x8000000000000000 ) ) ; } return packFloatx80 ( aSign , 0 , 0 ) ; } lastBitMask = 1 ; lastBitMask <<= 0x403E - aExp ; roundBitsMask = lastBitMask - 1 ; z = a ; roundingMode = float_rounding_mode ; if ( roundingMode == float_round_nearest_even ) { z . low += lastBitMask >> 1 ; if ( ( z . low & roundBitsMask ) == 0 ) z . low &= ~ lastBitMask ; } else if ( roundingMode != float_round_to_zero ) { if ( extractFloatx80Sign ( z ) ^ ( roundingMode == float_round_up ) ) { z . low += roundBitsMask ; } } z . low &= ~ roundBitsMask ; if ( z . low == 0 ) { ++ z . high ; z . low = LIT64 ( 0x8000000000000000 ) ; } if ( z . low != a . low ) float_exception_flags |= float_flag_inexact ; return z ; }
Rounds the extended double-precision floating-point value `a' to an integer,
and returns the result as an extended quadruple-precision floating-point
value.
Rounds the extended double - precision floating - point value ` a ' to an integer and returns the result as an extended quadruple - precision floating - point value .