kernels/linux-2.4.0/arch/arm/nwfpe/softfloat.c
/*
-------------------------------------------------------------------------------
Takes a 64-bit fixed-point value `absZ' with binary point between bits 6
and 7, and returns the properly rounded 32-bit integer corresponding to the
input.  If `zSign' is nonzero, the input is negated before being converted
to an integer.  Bit 63 of `absZ' must be zero.  Ordinarily, the fixed-point
input is simply rounded to an integer, with the inexact exception raised if
the input cannot be represented exactly as an integer.  If the fixed-point
input is too large, however, the invalid exception is raised and the largest
positive or negative integer is returned.
-------------------------------------------------------------------------------
*/
Takes a 64-bit fixed-point value `absZ' with binary point between bits 6
and 7, and returns the properly rounded 32-bit integer corresponding to the
input.  If `zSign' is nonzero, the input is negated before being converted
to an integer.  Bit 63 of `absZ' must be zero.  Ordinarily, the fixed-point
input is simply rounded to an integer, with the inexact exception raised if
the input cannot be represented exactly as an integer.  If the fixed-point
input is too large, however, the invalid exception is raised and the largest
positive or negative integer is returned.
Takes a 64 - bit fixed - point value ` absZ ' with binary point between bits 6 and 7 and returns the properly rounded 32 - bit integer corresponding to the input . If ` zSign ' is nonzero the input is negated before being converted to an integer . Bit 63 of ` absZ ' must be zero . Ordinarily the fixed - point input is simply rounded to an integer with the inexact exception raised if the input cannot be represented exactly as an integer . If the fixed - point input is too large however the invalid exception is raised and the largest positive or negative integer is returned .
static int32 roundAndPackInt32( flag zSign, bits64 absZ )
{
    int8 roundingMode;
    flag roundNearestEven;
    int8 roundIncrement, roundBits;
    int32 z;
    roundingMode = float_rounding_mode;
    roundNearestEven = ( roundingMode == float_round_nearest_even );
    roundIncrement = 0x40;
    if ( ! roundNearestEven ) {
        if ( roundingMode == float_round_to_zero ) {
            roundIncrement = 0;
        }
        else {
            roundIncrement = 0x7F;
            if ( zSign ) {
                if ( roundingMode == float_round_up ) roundIncrement = 0;
            }
            else {
                if ( roundingMode == float_round_down ) roundIncrement = 0;
            }
        }
    }
    roundBits = absZ & 0x7F;
    absZ = ( absZ + roundIncrement )>>7;
    absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
    z = absZ;
    if ( zSign ) z = - z;
    if ( ( absZ>>32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) {
        float_exception_flags |= float_flag_invalid;
        return zSign ? 0x80000000 : 0x7FFFFFFF;
    }
    if ( roundBits ) float_exception_flags |= float_flag_inexact;
    return z;
}
static int32 roundAndPackInt32 ( flag zSign , bits64 absZ ) { int8 roundingMode ; flag roundNearestEven ; int8 roundIncrement , roundBits ; int32 z ; roundingMode = float_rounding_mode ; roundNearestEven = ( roundingMode == float_round_nearest_even ) ; roundIncrement = 0x40 ; if ( ! roundNearestEven ) { if ( roundingMode == float_round_to_zero ) { roundIncrement = 0 ; } else { roundIncrement = 0x7F ; if ( zSign ) { if ( roundingMode == float_round_up ) roundIncrement = 0 ; } else { if ( roundingMode == float_round_down ) roundIncrement = 0 ; } } } roundBits = absZ & 0x7F ; absZ = ( absZ + roundIncrement ) >> 7 ; absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven ) ; z = absZ ; if ( zSign ) z = - z ; if ( ( absZ >> 32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) { float_exception_flags |= float_flag_invalid ; return zSign ? 0x80000000 : 0x7FFFFFFF ; } if ( roundBits ) float_exception_flags |= float_flag_inexact ; return z ; }
Takes a 64-bit fixed-point value `absZ' with binary point between bits 6
and 7, and returns the properly rounded 32-bit integer corresponding to the
input.
Takes a 64 - bit fixed - point value ` absZ ' with binary point between bits 6 and 7 and returns the properly rounded 32 - bit integer corresponding to the input .