| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769 | /*===============================================================================This C source file is part of the SoftFloat IEC/IEEE Floating-pointArithmetic Package, Release 2.Written by John R. Hauser.  This work was made possible in part by theInternational Computer Science Institute, located at Suite 600, 1947 CenterStreet, Berkeley, California 94704.  Funding was partially provided by theNational Science Foundation under grant MIP-9311980.  The original versionof this code was written as part of a project to build a fixed-point vectorprocessor in collaboration with the University of California at Berkeley,overseen by Profs. Nelson Morgan and John Wawrzynek.  More informationis available through the web pagehttp://www.jhauser.us/arithmetic/SoftFloat-2b/SoftFloat-source.txtTHIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable efforthas been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL ATTIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TOPERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANYAND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.Derivative works are acceptable, even for commercial purposes, so long as(1) they include prominent notice that the work is derivative, and (2) theyinclude prominent notice akin to these three paragraphs for those parts ofthis code that are retained.===============================================================================*/#include <asm/div64.h>#include "fpa11.h"//#include "milieu.h"//#include "softfloat.h"/*-------------------------------------------------------------------------------Primitive arithmetic functions, including multi-word arithmetic, anddivision and square root approximations.  (Can be specialized to target ifdesired.)-------------------------------------------------------------------------------*/#include "softfloat-macros"/*-------------------------------------------------------------------------------Functions and definitions to determine:  (1) whether tininess for underflowis detected before or after rounding by default, (2) what (if anything)happens when exceptions are raised, (3) how signaling NaNs are distinguishedfrom quiet NaNs, (4) the default generated quiet NaNs, and (5) how NaNsare propagated from function inputs to output.  These details are target-specific.-------------------------------------------------------------------------------*/#include "softfloat-specialize"/*-------------------------------------------------------------------------------Takes a 64-bit fixed-point value `absZ' with binary point between bits 6and 7, and returns the properly rounded 32-bit integer corresponding to theinput.  If `zSign' is nonzero, the input is negated before being convertedto an integer.  Bit 63 of `absZ' must be zero.  Ordinarily, the fixed-pointinput is simply rounded to an integer, with the inexact exception raised ifthe input cannot be represented exactly as an integer.  If the fixed-pointinput is too large, however, the invalid exception is raised and the largestpositive or negative integer is returned.-------------------------------------------------------------------------------*/static int32 roundAndPackInt32( struct roundingData *roundData, flag zSign, bits64 absZ ){    int8 roundingMode;    flag roundNearestEven;    int8 roundIncrement, roundBits;    int32 z;    roundingMode = roundData->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 ) ) ) {        roundData->exception |= float_flag_invalid;        return zSign ? 0x80000000 : 0x7FFFFFFF;    }    if ( roundBits ) roundData->exception |= float_flag_inexact;    return z;}/*-------------------------------------------------------------------------------Returns the fraction bits of the single-precision floating-point value `a'.-------------------------------------------------------------------------------*/INLINE bits32 extractFloat32Frac( float32 a ){    return a & 0x007FFFFF;}/*-------------------------------------------------------------------------------Returns the exponent bits of the single-precision floating-point value `a'.-------------------------------------------------------------------------------*/INLINE int16 extractFloat32Exp( float32 a ){    return ( a>>23 ) & 0xFF;}/*-------------------------------------------------------------------------------Returns the sign bit of the single-precision floating-point value `a'.-------------------------------------------------------------------------------*/#if 0	/* in softfloat.h */INLINE flag extractFloat32Sign( float32 a ){    return a>>31;}#endif/*-------------------------------------------------------------------------------Normalizes the subnormal single-precision floating-point value representedby the denormalized significand `aSig'.  The normalized exponent andsignificand are stored at the locations pointed to by `zExpPtr' and`zSigPtr', respectively.-------------------------------------------------------------------------------*/static void normalizeFloat32Subnormal( bits32 aSig, int16 *zExpPtr, bits32 *zSigPtr ){    int8 shiftCount;    shiftCount = countLeadingZeros32( aSig ) - 8;    *zSigPtr = aSig<<shiftCount;    *zExpPtr = 1 - shiftCount;}/*-------------------------------------------------------------------------------Packs the sign `zSign', exponent `zExp', and significand `zSig' into asingle-precision floating-point value, returning the result.  After beingshifted into the proper positions, the three fields are simply addedtogether to form the result.  This means that any integer portion of `zSig'will be added into the exponent.  Since a properly normalized significandwill have an integer portion equal to 1, the `zExp' input should be 1 lessthan the desired result exponent whenever `zSig' is a complete, normalizedsignificand.-------------------------------------------------------------------------------*/INLINE float32 packFloat32( flag zSign, int16 zExp, bits32 zSig ){#if 0   float32 f;   __asm__("@ packFloat32				\n\   	    mov %0, %1, asl #31				\n\   	    orr %0, %2, asl #23				\n\   	    orr %0, %3"   	    : /* no outputs */   	    : "g" (f), "g" (zSign), "g" (zExp), "g" (zSig)   	    : "cc");   return f;#else    return ( ( (bits32) zSign )<<31 ) + ( ( (bits32) zExp )<<23 ) + zSig;#endif }/*-------------------------------------------------------------------------------Takes an abstract floating-point value having sign `zSign', exponent `zExp',and significand `zSig', and returns the proper single-precision floating-point value corresponding to the abstract input.  Ordinarily, the abstractvalue is simply rounded and packed into the single-precision format, withthe inexact exception raised if the abstract input cannot be representedexactly.  If the abstract value is too large, however, the overflow andinexact exceptions are raised and an infinity or maximal finite value isreturned.  If the abstract value is too small, the input value is rounded toa subnormal number, and the underflow and inexact exceptions are raised ifthe abstract input cannot be represented exactly as a subnormal single-precision floating-point number.    The input significand `zSig' has its binary point between bits 30and 29, which is 7 bits to the left of the usual location.  This shiftedsignificand must be normalized or smaller.  If `zSig' is not normalized,`zExp' must be 0; in that case, the result returned is a subnormal number,and it must not require rounding.  In the usual case that `zSig' isnormalized, `zExp' must be 1 less than the ``true'' floating-point exponent.The handling of underflow and overflow follows the IEC/IEEE Standard forBinary Floating-point Arithmetic.-------------------------------------------------------------------------------*/static float32 roundAndPackFloat32( struct roundingData *roundData, flag zSign, int16 zExp, bits32 zSig ){    int8 roundingMode;    flag roundNearestEven;    int8 roundIncrement, roundBits;    flag isTiny;    roundingMode = roundData->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 = zSig & 0x7F;    if ( 0xFD <= (bits16) zExp ) {        if (    ( 0xFD < zExp )             || (    ( zExp == 0xFD )                  && ( (sbits32) ( zSig + roundIncrement ) < 0 ) )           ) {            roundData->exception |= float_flag_overflow | float_flag_inexact;            return packFloat32( zSign, 0xFF, 0 ) - ( roundIncrement == 0 );        }        if ( zExp < 0 ) {            isTiny =                   ( float_detect_tininess == float_tininess_before_rounding )                || ( zExp < -1 )                || ( zSig + roundIncrement < 0x80000000 );            shift32RightJamming( zSig, - zExp, &zSig );            zExp = 0;            roundBits = zSig & 0x7F;            if ( isTiny && roundBits ) roundData->exception |= float_flag_underflow;        }    }    if ( roundBits ) roundData->exception |= float_flag_inexact;    zSig = ( zSig + roundIncrement )>>7;    zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );    if ( zSig == 0 ) zExp = 0;    return packFloat32( zSign, zExp, zSig );}/*-------------------------------------------------------------------------------Takes an abstract floating-point value having sign `zSign', exponent `zExp',and significand `zSig', and returns the proper single-precision floating-point value corresponding to the abstract input.  This routine is just like`roundAndPackFloat32' except that `zSig' does not have to be normalized inany way.  In all cases, `zExp' must be 1 less than the ``true'' floating-point exponent.-------------------------------------------------------------------------------*/static float32 normalizeRoundAndPackFloat32( struct roundingData *roundData, flag zSign, int16 zExp, bits32 zSig ){    int8 shiftCount;    shiftCount = countLeadingZeros32( zSig ) - 1;    return roundAndPackFloat32( roundData, zSign, zExp - shiftCount, zSig<<shiftCount );}/*-------------------------------------------------------------------------------Returns the fraction bits of the double-precision floating-point value `a'.-------------------------------------------------------------------------------*/INLINE bits64 extractFloat64Frac( float64 a ){    return a & LIT64( 0x000FFFFFFFFFFFFF );}/*-------------------------------------------------------------------------------Returns the exponent bits of the double-precision floating-point value `a'.-------------------------------------------------------------------------------*/INLINE int16 extractFloat64Exp( float64 a ){    return ( a>>52 ) & 0x7FF;}/*-------------------------------------------------------------------------------Returns the sign bit of the double-precision floating-point value `a'.-------------------------------------------------------------------------------*/#if 0	/* in softfloat.h */INLINE flag extractFloat64Sign( float64 a ){    return a>>63;}#endif/*-------------------------------------------------------------------------------Normalizes the subnormal double-precision floating-point value representedby the denormalized significand `aSig'.  The normalized exponent andsignificand are stored at the locations pointed to by `zExpPtr' and`zSigPtr', respectively.-------------------------------------------------------------------------------*/static void normalizeFloat64Subnormal( bits64 aSig, int16 *zExpPtr, bits64 *zSigPtr ){    int8 shiftCount;    shiftCount = countLeadingZeros64( aSig ) - 11;    *zSigPtr = aSig<<shiftCount;    *zExpPtr = 1 - shiftCount;}/*-------------------------------------------------------------------------------Packs the sign `zSign', exponent `zExp', and significand `zSig' into adouble-precision floating-point value, returning the result.  After beingshifted into the proper positions, the three fields are simply addedtogether to form the result.  This means that any integer portion of `zSig'will be added into the exponent.  Since a properly normalized significandwill have an integer portion equal to 1, the `zExp' input should be 1 lessthan the desired result exponent whenever `zSig' is a complete, normalizedsignificand.-------------------------------------------------------------------------------*/INLINE float64 packFloat64( flag zSign, int16 zExp, bits64 zSig ){    return ( ( (bits64) zSign )<<63 ) + ( ( (bits64) zExp )<<52 ) + zSig;}/*-------------------------------------------------------------------------------Takes an abstract floating-point value having sign `zSign', exponent `zExp',and significand `zSig', and returns the proper double-precision floating-point value corresponding to the abstract input.  Ordinarily, the abstractvalue is simply rounded and packed into the double-precision format, withthe inexact exception raised if the abstract input cannot be representedexactly.  If the abstract value is too large, however, the overflow andinexact exceptions are raised and an infinity or maximal finite value isreturned.  If the abstract value is too small, the input value is rounded toa subnormal number, and the underflow and inexact exceptions are raised ifthe abstract input cannot be represented exactly as a subnormal double-precision floating-point number.    The input significand `zSig' has its binary point between bits 62and 61, which is 10 bits to the left of the usual location.  This shiftedsignificand must be normalized or smaller.  If `zSig' is not normalized,`zExp' must be 0; in that case, the result returned is a subnormal number,and it must not require rounding.  In the usual case that `zSig' isnormalized, `zExp' must be 1 less than the ``true'' floating-point exponent.The handling of underflow and overflow follows the IEC/IEEE Standard forBinary Floating-point Arithmetic.-------------------------------------------------------------------------------*/static float64 roundAndPackFloat64( struct roundingData *roundData, flag zSign, int16 zExp, bits64 zSig ){    int8 roundingMode;    flag roundNearestEven;    int16 roundIncrement, roundBits;    flag isTiny;    roundingMode = roundData->mode;    roundNearestEven = ( roundingMode == float_round_nearest_even );    roundIncrement = 0x200;    if ( ! roundNearestEven ) {        if ( roundingMode == float_round_to_zero ) {            roundIncrement = 0;        }        else {            roundIncrement = 0x3FF;            if ( zSign ) {                if ( roundingMode == float_round_up ) roundIncrement = 0;            }            else {                if ( roundingMode == float_round_down ) roundIncrement = 0;            }        }    }    roundBits = zSig & 0x3FF;    if ( 0x7FD <= (bits16) zExp ) {        if (    ( 0x7FD < zExp )             || (    ( zExp == 0x7FD )                  && ( (sbits64) ( zSig + roundIncrement ) < 0 ) )           ) {            //register int lr = __builtin_return_address(0);            //printk("roundAndPackFloat64 called from 0x%08x\n",lr);            roundData->exception |= float_flag_overflow | float_flag_inexact;            return packFloat64( zSign, 0x7FF, 0 ) - ( roundIncrement == 0 );        }        if ( zExp < 0 ) {            isTiny =                   ( float_detect_tininess == float_tininess_before_rounding )                || ( zExp < -1 )                || ( zSig + roundIncrement < LIT64( 0x8000000000000000 ) );            shift64RightJamming( zSig, - zExp, &zSig );            zExp = 0;            roundBits = zSig & 0x3FF;            if ( isTiny && roundBits ) roundData->exception |= float_flag_underflow;        }    }    if ( roundBits ) roundData->exception |= float_flag_inexact;    zSig = ( zSig + roundIncrement )>>10;    zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );    if ( zSig == 0 ) zExp = 0;    return packFloat64( zSign, zExp, zSig );}/*-------------------------------------------------------------------------------Takes an abstract floating-point value having sign `zSign', exponent `zExp',and significand `zSig', and returns the proper double-precision floating-point value corresponding to the abstract input.  This routine is just like`roundAndPackFloat64' except that `zSig' does not have to be normalized inany way.  In all cases, `zExp' must be 1 less than the ``true'' floating-point exponent.-------------------------------------------------------------------------------*/static float64 normalizeRoundAndPackFloat64( struct roundingData *roundData, flag zSign, int16 zExp, bits64 zSig ){    int8 shiftCount;    shiftCount = countLeadingZeros64( zSig ) - 1;    return roundAndPackFloat64( roundData, zSign, zExp - shiftCount, zSig<<shiftCount );}#ifdef FLOATX80/*-------------------------------------------------------------------------------Returns the fraction bits of the extended double-precision floating-pointvalue `a'.-------------------------------------------------------------------------------*/INLINE bits64 extractFloatx80Frac( floatx80 a ){    return a.low;}/*-------------------------------------------------------------------------------Returns the exponent bits of the extended double-precision floating-pointvalue `a'.-------------------------------------------------------------------------------*/INLINE int32 extractFloatx80Exp( floatx80 a ){    return a.high & 0x7FFF;}/*-------------------------------------------------------------------------------Returns the sign bit of the extended double-precision floating-point value`a'.-------------------------------------------------------------------------------*/INLINE flag extractFloatx80Sign( floatx80 a ){    return a.high>>15;}/*-------------------------------------------------------------------------------Normalizes the subnormal extended double-precision floating-point valuerepresented by the denormalized significand `aSig'.  The normalized exponentand significand are stored at the locations pointed to by `zExpPtr' and`zSigPtr', respectively.-------------------------------------------------------------------------------*/static void normalizeFloatx80Subnormal( bits64 aSig, int32 *zExpPtr, bits64 *zSigPtr ){    int8 shiftCount;    shiftCount = countLeadingZeros64( aSig );    *zSigPtr = aSig<<shiftCount;    *zExpPtr = 1 - shiftCount;}/*-------------------------------------------------------------------------------Packs the sign `zSign', exponent `zExp', and significand `zSig' into anextended double-precision floating-point value, returning the result.-------------------------------------------------------------------------------*/INLINE floatx80 packFloatx80( flag zSign, int32 zExp, bits64 zSig ){    floatx80 z;    z.low = zSig;    z.high = ( ( (bits16) zSign )<<15 ) + zExp;    z.__padding = 0;    return z;}/*-------------------------------------------------------------------------------Takes an abstract floating-point value having sign `zSign', exponent `zExp',and extended significand formed by the concatenation of `zSig0' and `zSig1',and returns the proper extended double-precision floating-point valuecorresponding to the abstract input.  Ordinarily, the abstract value isrounded and packed into the extended double-precision format, with theinexact exception raised if the abstract input cannot be representedexactly.  If the abstract value is too large, however, the overflow andinexact exceptions are raised and an infinity or maximal finite value isreturned.  If the abstract value is too small, the input value is rounded toa subnormal number, and the underflow and inexact exceptions are raised ifthe abstract input cannot be represented exactly as a subnormal extendeddouble-precision floating-point number.    If `roundingPrecision' is 32 or 64, the result is rounded to the samenumber of bits as single or double precision, respectively.  Otherwise, theresult is rounded to the full precision of the extended double-precisionformat.    The input significand must be normalized or smaller.  If the inputsignificand is not normalized, `zExp' must be 0; in that case, the resultreturned is a subnormal number, and it must not require rounding.  Thehandling of underflow and overflow follows the IEC/IEEE Standard for BinaryFloating-point Arithmetic.-------------------------------------------------------------------------------*/static floatx80 roundAndPackFloatx80(     struct roundingData *roundData, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1 ){    int8 roundingMode, roundingPrecision;    flag roundNearestEven, increment, isTiny;    int64 roundIncrement, roundMask, roundBits;    roundingMode = roundData->mode;    roundingPrecision = roundData->precision;    roundNearestEven = ( roundingMode == float_round_nearest_even );    if ( roundingPrecision == 80 ) goto precision80;    if ( roundingPrecision == 64 ) {        roundIncrement = LIT64( 0x0000000000000400 );        roundMask = LIT64( 0x00000000000007FF );    }    else if ( roundingPrecision == 32 ) {        roundIncrement = LIT64( 0x0000008000000000 );        roundMask = LIT64( 0x000000FFFFFFFFFF );    }    else {        goto precision80;    }    zSig0 |= ( zSig1 != 0 );    if ( ! roundNearestEven ) {        if ( roundingMode == float_round_to_zero ) {            roundIncrement = 0;        }        else {            roundIncrement = roundMask;            if ( zSign ) {                if ( roundingMode == float_round_up ) roundIncrement = 0;            }            else {                if ( roundingMode == float_round_down ) roundIncrement = 0;            }        }    }    roundBits = zSig0 & roundMask;    if ( 0x7FFD <= (bits32) ( zExp - 1 ) ) {        if (    ( 0x7FFE < zExp )             || ( ( zExp == 0x7FFE ) && ( zSig0 + roundIncrement < zSig0 ) )           ) {            goto overflow;        }        if ( zExp <= 0 ) {            isTiny =                   ( float_detect_tininess == float_tininess_before_rounding )                || ( zExp < 0 )                || ( zSig0 <= zSig0 + roundIncrement );            shift64RightJamming( zSig0, 1 - zExp, &zSig0 );            zExp = 0;            roundBits = zSig0 & roundMask;            if ( isTiny && roundBits ) roundData->exception |= float_flag_underflow;            if ( roundBits ) roundData->exception |= float_flag_inexact;            zSig0 += roundIncrement;            if ( (sbits64) zSig0 < 0 ) zExp = 1;            roundIncrement = roundMask + 1;            if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {                roundMask |= roundIncrement;            }            zSig0 &= ~ roundMask;            return packFloatx80( zSign, zExp, zSig0 );        }    }    if ( roundBits ) roundData->exception |= float_flag_inexact;    zSig0 += roundIncrement;    if ( zSig0 < roundIncrement ) {        ++zExp;        zSig0 = LIT64( 0x8000000000000000 );    }    roundIncrement = roundMask + 1;    if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {        roundMask |= roundIncrement;    }    zSig0 &= ~ roundMask;    if ( zSig0 == 0 ) zExp = 0;    return packFloatx80( zSign, zExp, zSig0 ); precision80:    increment = ( (sbits64) zSig1 < 0 );    if ( ! roundNearestEven ) {        if ( roundingMode == float_round_to_zero ) {            increment = 0;        }        else {            if ( zSign ) {                increment = ( roundingMode == float_round_down ) && zSig1;            }            else {                increment = ( roundingMode == float_round_up ) && zSig1;            }        }    }    if ( 0x7FFD <= (bits32) ( zExp - 1 ) ) {        if (    ( 0x7FFE < zExp )             || (    ( zExp == 0x7FFE )                  && ( zSig0 == LIT64( 0xFFFFFFFFFFFFFFFF ) )                  && increment                )           ) {            roundMask = 0; overflow:            roundData->exception |= float_flag_overflow | float_flag_inexact;            if (    ( roundingMode == float_round_to_zero )                 || ( zSign && ( roundingMode == float_round_up ) )                 || ( ! zSign && ( roundingMode == float_round_down ) )               ) {                return packFloatx80( zSign, 0x7FFE, ~ roundMask );            }            return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );        }        if ( zExp <= 0 ) {            isTiny =                   ( float_detect_tininess == float_tininess_before_rounding )                || ( zExp < 0 )                || ! increment                || ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) );            shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );            zExp = 0;            if ( isTiny && zSig1 ) roundData->exception |= float_flag_underflow;            if ( zSig1 ) roundData->exception |= float_flag_inexact;            if ( roundNearestEven ) {                increment = ( (sbits64) zSig1 < 0 );            }            else {                if ( zSign ) {                    increment = ( roundingMode == float_round_down ) && zSig1;                }                else {                    increment = ( roundingMode == float_round_up ) && zSig1;                }            }            if ( increment ) {                ++zSig0;                zSig0 &= ~ ( ( zSig1 + zSig1 == 0 ) & roundNearestEven );                if ( (sbits64) zSig0 < 0 ) zExp = 1;            }            return packFloatx80( zSign, zExp, zSig0 );        }    }    if ( zSig1 ) roundData->exception |= float_flag_inexact;    if ( increment ) {        ++zSig0;        if ( zSig0 == 0 ) {            ++zExp;            zSig0 = LIT64( 0x8000000000000000 );        }        else {            zSig0 &= ~ ( ( zSig1 + zSig1 == 0 ) & roundNearestEven );        }    }    else {        if ( zSig0 == 0 ) zExp = 0;    }        return packFloatx80( zSign, zExp, zSig0 );}/*-------------------------------------------------------------------------------Takes an abstract floating-point value having sign `zSign', exponent`zExp', and significand formed by the concatenation of `zSig0' and `zSig1',and returns the proper extended double-precision floating-point valuecorresponding to the abstract input.  This routine is just like`roundAndPackFloatx80' except that the input significand does not have to benormalized.-------------------------------------------------------------------------------*/static floatx80 normalizeRoundAndPackFloatx80(     struct roundingData *roundData, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1 ){    int8 shiftCount;    if ( zSig0 == 0 ) {        zSig0 = zSig1;        zSig1 = 0;        zExp -= 64;    }    shiftCount = countLeadingZeros64( zSig0 );    shortShift128Left( zSig0, zSig1, shiftCount, &zSig0, &zSig1 );    zExp -= shiftCount;    return        roundAndPackFloatx80( roundData, zSign, zExp, zSig0, zSig1 );}#endif/*-------------------------------------------------------------------------------Returns the result of converting the 32-bit two's complement integer `a' tothe single-precision floating-point format.  The conversion is performedaccording to the IEC/IEEE Standard for Binary Floating-point Arithmetic.-------------------------------------------------------------------------------*/float32 int32_to_float32(struct roundingData *roundData, int32 a){    flag zSign;    if ( a == 0 ) return 0;    if ( a == 0x80000000 ) return packFloat32( 1, 0x9E, 0 );    zSign = ( a < 0 );    return normalizeRoundAndPackFloat32( roundData, zSign, 0x9C, zSign ? - a : a );
 |