[ANN] Number readFrom: light version rounding to nearest float

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ANN] Number readFrom: light version rounding to nearest float

Nicolas Cellier-3

This is related to squeak-dev subjects
 - Numerics question: reading floating point constants
 - Fun with Number readFrom: What should we do ?

I proposed a first version of SqNumberParser built upon Bellerophon algorithm
(using 64 bits arithmetic instead of 53 to get a correct result).
Unfortunately, this solution was quite heavy in my opinion (using a new
ArbitraryPrecisionFloat class).
It was not that efficient anyway because no access to native 64bit extended
precision arithmetic was provided from within squeak (all was emulated).

The other solution i suggested is now working. Two patches correcting
Integer>>asFloat and Fraction>>asFloat need simply being loaded from
http://bugs.impara.de/view.php?id=3564 and
http://bugs.impara.de/view.php?id=3568

Then, no more need for BellerophonAlgorithm nor ArbitraryPrecisionFloat...
Conversion is slow, but often a little faster than original readFrom:.
Solution is now a good candidate for base image inclusion (3.9 but also
earlier releases).

TODO: create a specific error like NumberParserError or NumberParserException.

Anyone interested, please do your own tests and let me know of any bug.

Nicolas



Kernel-Number-SqNumberParserV2.1.cs.gz (5K) Download Attachment