[squeak-dev] Experimental classes for controlling Float printing format

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Tue May 22 22:53:37 UTC 2012


Here is a set of experimental classes for controlling floating point
output format.
The ideas are:
- 1) we can extend these formatting capabilities without creating a
bunch of new messages combinations
      instead, we just have parameterized FloatPrinter object (+
subclasses), and use cascade of elementary messages
      The capabilities are right now limited to scientific, free
format, fixed point and storeOn: format.
      But features are growable, and we could as well control
localization, thousand separators, padding (total width, width left of
fraction point, force + sign, etc...)
- 2) The complex algorithm for printing accurately
(Burger/Dybvig/Steele) has been split into private methods in order to
be reusable by various format (fixed number of decimal places and
fixed number of significand digits)
      I choosed to store above algorithm internal states in inst var
in order to avoid explosion of meaningless parameters...
      This turns the functional implementation into a stateful
implementation, but encapsulated in a class and private messages...
      It's a bit the same design choice as SqNumberParser.
      Having more comments is also a benefit (it's still preferable to
read the paper though)

The good news is that, despite parametrization and FloatPrinter
instantiation, slow down is typically limited to 3% (we can optimize
the default case eventually)...

Comments, extensions and alternate design are welcome.

Nicolas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Experimental.st
Type: application/octet-stream
Size: 16100 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20120523/3aaa0e12/Experimental-0001.obj


More information about the Squeak-dev mailing list