|
@@ -876,3 +876,88 @@ int32 float32_to_int32_round_to_zero( float32 a )
|
|
shiftCount = aExp - 0x9E;
|
|
shiftCount = aExp - 0x9E;
|
|
if ( 0 <= shiftCount ) {
|
|
if ( 0 <= shiftCount ) {
|
|
if ( a == 0xCF000000 ) return 0x80000000;
|
|
if ( a == 0xCF000000 ) return 0x80000000;
|
|
|
|
+ float_raise( float_flag_invalid );
|
|
|
|
+ if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) return 0x7FFFFFFF;
|
|
|
|
+ return 0x80000000;
|
|
|
|
+ }
|
|
|
|
+ else if ( aExp <= 0x7E ) {
|
|
|
|
+ if ( aExp | aSig ) float_raise( float_flag_inexact );
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ aSig = ( aSig | 0x00800000 )<<8;
|
|
|
|
+ z = aSig>>( - shiftCount );
|
|
|
|
+ if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) {
|
|
|
|
+ float_raise( float_flag_inexact );
|
|
|
|
+ }
|
|
|
|
+ return aSign ? - z : z;
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+-------------------------------------------------------------------------------
|
|
|
|
+Returns the result of converting the single-precision floating-point value
|
|
|
|
+`a' to the double-precision floating-point format. The conversion is
|
|
|
|
+performed according to the IEC/IEEE Standard for Binary Floating-point
|
|
|
|
+Arithmetic.
|
|
|
|
+-------------------------------------------------------------------------------
|
|
|
|
+*/
|
|
|
|
+float64 float32_to_float64( float32 a )
|
|
|
|
+{
|
|
|
|
+ flag aSign;
|
|
|
|
+ int16 aExp;
|
|
|
|
+ bits32 aSig;
|
|
|
|
+
|
|
|
|
+ aSig = extractFloat32Frac( a );
|
|
|
|
+ aExp = extractFloat32Exp( a );
|
|
|
|
+ aSign = extractFloat32Sign( a );
|
|
|
|
+ if ( aExp == 0xFF ) {
|
|
|
|
+ if ( aSig ) return commonNaNToFloat64( float32ToCommonNaN( a ) );
|
|
|
|
+ return packFloat64( aSign, 0x7FF, 0 );
|
|
|
|
+ }
|
|
|
|
+ if ( aExp == 0 ) {
|
|
|
|
+ if ( aSig == 0 ) return packFloat64( aSign, 0, 0 );
|
|
|
|
+ normalizeFloat32Subnormal( aSig, &aExp, &aSig );
|
|
|
|
+ --aExp;
|
|
|
|
+ }
|
|
|
|
+ return packFloat64( aSign, aExp + 0x380, ( (bits64) aSig )<<29 );
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#ifdef FLOATX80
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+-------------------------------------------------------------------------------
|
|
|
|
+Returns the result of converting the single-precision floating-point value
|
|
|
|
+`a' to the extended double-precision floating-point format. The conversion
|
|
|
|
+is performed according to the IEC/IEEE Standard for Binary Floating-point
|
|
|
|
+Arithmetic.
|
|
|
|
+-------------------------------------------------------------------------------
|
|
|
|
+*/
|
|
|
|
+floatx80 float32_to_floatx80( float32 a )
|
|
|
|
+{
|
|
|
|
+ flag aSign;
|
|
|
|
+ int16 aExp;
|
|
|
|
+ bits32 aSig;
|
|
|
|
+
|
|
|
|
+ aSig = extractFloat32Frac( a );
|
|
|
|
+ aExp = extractFloat32Exp( a );
|
|
|
|
+ aSign = extractFloat32Sign( a );
|
|
|
|
+ if ( aExp == 0xFF ) {
|
|
|
|
+ if ( aSig ) return commonNaNToFloatx80( float32ToCommonNaN( a ) );
|
|
|
|
+ return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
|
|
|
|
+ }
|
|
|
|
+ if ( aExp == 0 ) {
|
|
|
|
+ if ( aSig == 0 ) return packFloatx80( aSign, 0, 0 );
|
|
|
|
+ normalizeFloat32Subnormal( aSig, &aExp, &aSig );
|
|
|
|
+ }
|
|
|
|
+ aSig |= 0x00800000;
|
|
|
|
+ return packFloatx80( aSign, aExp + 0x3F80, ( (bits64) aSig )<<40 );
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+-------------------------------------------------------------------------------
|
|
|
|
+Rounds the single-precision floating-point value `a' to an integer, and
|
|
|
|
+returns the result as a single-precision floating-point value. The
|