|
@@ -2159,3 +2159,55 @@ float64 float64_mul( struct roundingData *roundData, float64 a, float64 b )
|
|
|
if ( 0 <= (sbits64) ( zSig0<<1 ) ) {
|
|
|
zSig0 <<= 1;
|
|
|
--zExp;
|
|
|
+ }
|
|
|
+ return roundAndPackFloat64( roundData, zSign, zExp, zSig0 );
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+-------------------------------------------------------------------------------
|
|
|
+Returns the result of dividing the double-precision floating-point value `a'
|
|
|
+by the corresponding value `b'. The operation is performed according to
|
|
|
+the IEC/IEEE Standard for Binary Floating-point Arithmetic.
|
|
|
+-------------------------------------------------------------------------------
|
|
|
+*/
|
|
|
+float64 float64_div( struct roundingData *roundData, float64 a, float64 b )
|
|
|
+{
|
|
|
+ flag aSign, bSign, zSign;
|
|
|
+ int16 aExp, bExp, zExp;
|
|
|
+ bits64 aSig, bSig, zSig;
|
|
|
+ bits64 rem0, rem1;
|
|
|
+ bits64 term0, term1;
|
|
|
+
|
|
|
+ aSig = extractFloat64Frac( a );
|
|
|
+ aExp = extractFloat64Exp( a );
|
|
|
+ aSign = extractFloat64Sign( a );
|
|
|
+ bSig = extractFloat64Frac( b );
|
|
|
+ bExp = extractFloat64Exp( b );
|
|
|
+ bSign = extractFloat64Sign( b );
|
|
|
+ zSign = aSign ^ bSign;
|
|
|
+ if ( aExp == 0x7FF ) {
|
|
|
+ if ( aSig ) return propagateFloat64NaN( a, b );
|
|
|
+ if ( bExp == 0x7FF ) {
|
|
|
+ if ( bSig ) return propagateFloat64NaN( a, b );
|
|
|
+ roundData->exception |= float_flag_invalid;
|
|
|
+ return float64_default_nan;
|
|
|
+ }
|
|
|
+ return packFloat64( zSign, 0x7FF, 0 );
|
|
|
+ }
|
|
|
+ if ( bExp == 0x7FF ) {
|
|
|
+ if ( bSig ) return propagateFloat64NaN( a, b );
|
|
|
+ return packFloat64( zSign, 0, 0 );
|
|
|
+ }
|
|
|
+ if ( bExp == 0 ) {
|
|
|
+ if ( bSig == 0 ) {
|
|
|
+ if ( ( aExp | aSig ) == 0 ) {
|
|
|
+ roundData->exception |= float_flag_invalid;
|
|
|
+ return float64_default_nan;
|
|
|
+ }
|
|
|
+ roundData->exception |= float_flag_divbyzero;
|
|
|
+ return packFloat64( zSign, 0x7FF, 0 );
|
|
|
+ }
|
|
|
+ normalizeFloat64Subnormal( bSig, &bExp, &bSig );
|
|
|
+ }
|
|
|
+ if ( aExp == 0 ) {
|