[squeak-dev] Experimental classes for controlling Float printing
format
Lawson English
lenglish5 at cox.net
Tue May 22 23:06:46 UTC 2012
Take a look at the capabilities of the mpfr library. In the long run, it
might be good to be able to switch between the boxed float primitive of
squeak/pharo, and the extended capabilities of the external lib:
http://www.mpfr.org/ and the capabilities of mpfr might be a good
guideline for what an extended floating point class should be able to do.
Lawson
On 5/22/12 3:53 PM, Nicolas Cellier wrote:
> 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
>
>
--
Squeak from the very start (introduction to Squeak and Pharo Smalltalk for the (almost) complete and compleate beginner).
https://www.youtube.com/playlist?list=PL6601A198DF14788D&feature=view_all
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20120522/2d68b89f/attachment.htm
More information about the Squeak-dev
mailing list
|