arbitrary precision floats?
Viktor
vi.ki at worldonline.cz
Sun Nov 3 15:55:15 UTC 2002
Maybe something like this (?):
[some operations] doWithPrecision: 100.
Precision is thread-variable (Thread current precisionOf Floats).
Viktor
>
> 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
|