Float>>#asIEEE32BitWord

Philippe Marschall philippe.marschall at gmail.com
Wed Feb 22 05:48:56 UTC 2006


Hi

I think Float>>#asIEEE32BitWord is bugged for NaNs. Why?
Float nan asIEEE32BitWord printPaddedWith: $0 to: 32 base: 2
yields: '01111111100000000000000000000000'
which is excately the same as
Float infinity asIEEE32BitWord printPaddedWith: $0 to: 32 base: 2

so basically
sign: 0
exponent: 255
mantissa: 0

According to the class comment of Float and Google this is the correct
representation of positive inifinity. A NaN would have a non-zero
mantissa.

I think the bug is:
	exponent > 254 ifTrue:["Overflow"
		exponent := 255.
		mantissa := 0].
this should be:
	exponent > 254 ifTrue:["Overflow"
		exponent := 255.
		self isNaN ifFalse: [
			mantissa := 0 ]  ].

Does this make any sense?

Cheers
Philippe



More information about the Squeak-dev mailing list