On 7 January 2011 15:28, Aurelien Jarno <aurel...@aurel32.net> wrote: > On Thu, Jan 06, 2011 at 06:34:43PM +0000, Peter Maydell wrote: >> Implement versions of float*_is_any_nan() for the floatx80 and >> float128 types. >> >> Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> >> --- >> fpu/softfloat.h | 11 +++++++++++ >> 1 files changed, 11 insertions(+), 0 deletions(-) >> >> diff --git a/fpu/softfloat.h b/fpu/softfloat.h >> index f2104c6..ac81845 100644 >> --- a/fpu/softfloat.h >> +++ b/fpu/softfloat.h >> @@ -469,6 +469,11 @@ INLINE int floatx80_is_zero(floatx80 a) >> return (a.high & 0x7fff) == 0 && a.low == 0; >> } >> >> +INLINE int floatx80_is_any_nan(floatx80 a) >> +{ >> + return ((a.high & 0x7fff) == 0x7fff) && (a.low<<1); >> +} >> + >> #endif > > While this looks correct, this seems to say that our definition of > floatx80_is_quiet_nan() (for SNAN_BIT_IS_ZERO) is wrong as it is exactly > the same.
Hrm. I suspect this is confusion caused by floatx80 having an explicit hidden bit (most significant bit of the significand) where float32/float64 have an implicit hidden bit. I think floatx80_is_quiet_nan() must be wrong because: int floatx80_is_quiet_nan( floatx80 a ) { #if SNAN_BIT_IS_ONE bits64 aLow; aLow = a.low & ~ LIT64( 0x4000000000000000 ); return ( ( a.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( aLow<<1 ) && ( a.low == aLow ); #else return ( ( a.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( a.low<<1 ); #endif } the two halves of the ifdef ought to carve the space up into two disjoint halves, but you can see that the !SNAN_BIT_IS_ONE condition is a superset of the other. -- PMM