arbitrary precision floats?

Lex Spoon lex at cc.gatech.edu
Sat Nov 2 20:11:08 UTC 2002


"Viktor" <vi.ki at worldonline.cz> wrote:
> > The interface might look like:
> > 
> >     BigFloat setPrecision: 100. "100 decimal place precision."
> >     a := BigFloat fromFloat: 5.0.
> 
> 
> Not thread-safe.
> 

It's also not modular.  What happens when one module wants 100 places
and another wants 1000 ?  One of them will win and--especially if it's
the one with 100 places--the other module will suffer.

Per-float precision seems to be the most direct thing to do.  You have
to decide what precision each operation will return.  One reasonable
thing is to return the precision of the more precise number, but then
again some operations may want to increase or decrease precision.


I don't think adding lexical support would be anywhere close to as
difficult as implementing all the floating-point operations is going to
be!  Look at class Scanner....  I guess you might do:

	1.1e10p100

For a number with 100 bits of precision.

Oh, and if you specifically want *decimal* numbers, then it is likely
that the ANSI ScaledDecimal will do what you want.  Except *possibly*
for the lexical changes, I think this is available in the Squeak ANSI
patches.



-Lex



More information about the Squeak-dev mailing list