help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Re: [PATCH] fix FloatQ reading


From: Paolo Bonzini
Subject: [Help-smalltalk] Re: [PATCH] fix FloatQ reading
Date: Sat, 19 Sep 2009 19:02:37 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3

On 07/17/2009 12:10 AM, Nicolas Cellier wrote:
Too many lines of C for a source code analysis to my own taste :)
Maybe some very simple tests like:

self assert: 1.3q0 = (13/10) asFloatQ.

I wrote Float>>successor recently in Pharo, that can be a helper iin
such tests...

What about this instead:

predecessor
    | exponent |
    self isFinite ifFalse: [
            (self isNaN or: [self negative]) ifTrue: [^self].
            ^Float fmax].
    self = 0.0 ifTrue: [^Float fmin negated].
    exponent := self exponent.
    ^exponent < self class emin
        ifTrue: [self - Float fminDenormalized]
        ifFalse: [self - (Float epsilon timesTwoPower: exponent)]

and likewise with s/-/+/ for successor?

Feel free to add these to Pharo.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]