diff options
Diffstat (limited to 'source/extF80M_roundToInt.c')
-rw-r--r-- | source/extF80M_roundToInt.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/source/extF80M_roundToInt.c b/source/extF80M_roundToInt.c index 5c4f5f3..ff4ae87 100644 --- a/source/extF80M_roundToInt.c +++ b/source/extF80M_roundToInt.c @@ -2,7 +2,7 @@ /*============================================================================ This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic -Package, Release 3d, by John R. Hauser. +Package, Release 3e, by John R. Hauser. Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of California. All rights reserved. @@ -86,8 +86,8 @@ void sigA = aSPtr->signif; /*------------------------------------------------------------------------ *------------------------------------------------------------------------*/ - if ( ! (sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) { - if ( ! sigA ) { + if ( !(sigA & UINT64_C( 0x8000000000000000 )) && (exp != 0x7FFF) ) { + if ( !sigA ) { uiZ64 = signUI64; sigZ = 0; goto uiZ; @@ -100,7 +100,7 @@ void if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact; switch ( roundingMode ) { case softfloat_round_near_even: - if ( ! (sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break; + if ( !(sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) break; case softfloat_round_near_maxMag: if ( exp == 0x3FFE ) goto mag1; break; @@ -108,8 +108,12 @@ void if ( signUI64 ) goto mag1; break; case softfloat_round_max: - if ( ! signUI64 ) goto mag1; + if ( !signUI64 ) goto mag1; break; +#ifdef SOFTFLOAT_ROUND_ODD + case softfloat_round_odd: + goto mag1; +#endif } uiZ64 = signUI64; sigZ = 0; @@ -144,19 +148,22 @@ void sigZ += lastBitMask>>1; } else if ( roundingMode == softfloat_round_near_even ) { sigZ += lastBitMask>>1; - if ( ! (sigZ & roundBitsMask) ) sigZ &= ~lastBitMask; + if ( !(sigZ & roundBitsMask) ) sigZ &= ~lastBitMask; } else if ( roundingMode == (signUI64 ? softfloat_round_min : softfloat_round_max) ) { sigZ += roundBitsMask; } sigZ &= ~roundBitsMask; - if ( ! sigZ ) { + if ( !sigZ ) { ++uiZ64; sigZ = UINT64_C( 0x8000000000000000 ); } - if ( exact && (sigZ != sigA) ) { - softfloat_exceptionFlags |= softfloat_flag_inexact; + if ( sigZ != sigA ) { +#ifdef SOFTFLOAT_ROUND_ODD + if ( roundingMode == softfloat_round_odd ) sigZ |= lastBitMask; +#endif + if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact; } uiZ: zSPtr->signExp = uiZ64; |