arbitrary precision floats?

Michael Vanier mvanier at cs.caltech.edu
Mon Nov 4 23:37:17 UTC 2002


There are freely-available arbitrary-precision float libraries like GNU MP
which could in principle be used by squeak.  Otherwise your suggestion is a
good one.

Mike


> From: "Swan, Dean" <Dean_Swan at Mitel.COM>
> Date: Mon, 4 Nov 2002 13:31:47 -0500
> 
> Is there any reason why you can't just use instances of class 'Fraction' and format the results for display as required?  I don't think any implementation of "arbirtrary precision floats" is going to be much more efficient, especially with the large integers plugin.
> 
> 					-Dean Swan
> 
> 
> -----Original Message-----
> From: Michael Vanier [mailto:mvanier at cs.caltech.edu]
> Sent: Sunday, November 03, 2002 2:42 AM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: Re: arbitrary precision floats?
> 
> 
> 
> I agree with your criticisms.  However, what I want is to be able to set
> the float precision on a project-wide basis.  In other words, I want to be
> able to say "all BigFloats now have 10 decimal places" and do some
> computations.  If I suspect that the results are incorrect due to
> compounding of numerical errors, I want to be able to change this to 100
> decimal places in one place only and recompute my results.  It may not be
> thread safe or modular, but it's what I want to be able to do.  Having to
> adjust float precision in a zillion different places is simply
> unmaintainable.
> 
> Mike
> 
> > From: Lex Spoon <lex at cc.gatech.edu>
> > Date: Sat, 2 Nov 2002 15:11:08 -0500
> > 
> > "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