PackageDescription: SYSEXT-NumberPrinter


SYSEXT - Number Printer

Last published: September 14, 2018 by 'nice'

Defines 6 Classes
Extends 11 Classes


This package includes classes for printing Float accurately in 5 formats:
#basic for classical Float printOn:
#forStore for classical Float storeOn:
#freeFormat #scientific #fixed for versatile Float output formatting...

This package prints the SHORTEST decimal representation that is nearer to this Floating point value than to the adjacent Floating point values.
If decimals to binary floating point are correctly rounded too, then such printing is a good basis for REPL.

Implementation is based upon the algorithm outlined in:
Robert G. Burger and R. Kent Dybvig
Printing Floating Point Numbers Quickly and Accurately
ACM SIGPLAN 1996 Conference on Programming Language Design and Implementation
June 1996.
This algorithm is itself a variation of Guy Steele's dragon 4 implemented originally in scheme.

The implementation addresses the first goals that were to:
- split the modified dragon4 algorithm in reusable parts
- share these parts among various formatting options
- care of not degrading performance which already is low
- create a versatile float printer with classical C printf like formatting options

Limitations:

Code was taken from Squeak and may have some rough edge or squeakism.
Note that other Number classes are handled and can print as a Floating point value, but no other format is handled.
The architecture is not modular in the sense that it's hardly extensible.
For example, introducing comas to separate thousands requires changing too much code.
Extensibility would probably mean favour composition over current simplistic inheritance.