[squeak-dev] FloatConstants?

Bert Freudenberg bert at freudenbergs.de
Wed Dec 17 17:56:19 UTC 2014


On 17.12.2014, at 18:17, Chris Muller <asqueaker at gmail.com> wrote:
> 
>          Float>>#hashKey32
>               self == NegativeInfinity ifTrue: [ ^ 0 ].
>               self == Infinity ifTrue: [ ^ 4294967294 ].
>               self isNaN ifTrue: [ ^ 4294967295 ].
>               self == NegativeZero ifTrue:  [ ^ 2147483650 ].
>               "Smallest to largest negative IEEE 32-bit floats range
> from  (2147483649 to: 4286578687), so invert that range."
>               self negative ifTrue: [ ^ (4286578687 - self
> asIEEE32BitWord) + 1 ].
>               "We're positive.  IEEE positives range from (0 to: 2139095039)."
>               ^ self asIEEE32BitWord + 2147483651
> 
> Since I need _maximum_ speed, I do not wish the check for Infinites
> and NaN's, the special cases, to require a message send..

This is a Float method. You can use the NaN class variable directly.

- Bert -



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4142 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20141217/c2684067/smime.bin


More information about the Squeak-dev mailing list