Hi,

just try 1.0d-20 asExactFraction.
Float>>asExactFraction implementation will evaluate:

(1.0d-20 timesTwoPower: 1.0d-20 exponent + 1.0d-20 class precision)
truncated /
(1    bitShift:      1.0d-20 exponent + 1.0d-20 class precision)

That is 0/0

I guess mantissa is rather
        self timesTwoPower: self exponent negated + self class precision
Then, sign of self exponent negated + self class precision should be
discussed in order to avoid division by zero...

I propose this implementation:

| shift mantissa |
self checkCoercion.
shift := self exponent negated + self class precision.
mantissa := (self timesTwoPower: shift) truncated.
^shift negative
        ifTrue: [mantissa * (1 bitShift: shift negated)]
        ifFalse: [mantissa / (1 bitShift: shift)]

Nicolas Cellier



_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to