[DGD] Re: Math kfuns

Gregory D Lewis glewis at maths.adelaide.edu.au
Tue May 12 04:45:14 CEST 1998


> > I suspect, without testing, that most compilers stick to the relevant
> > IEEE/ANSI standard on this.  I think it would be useful to at least have
> > a kfun package which included say the trig functions and a pow function.
> > While compilers may not produce _exactly_ the same result they will all be
> > "close enough" for almost all intents and purposes.
> 
> "Most compilers" is not enough.  "Close enough" is not enough.
> Whenever I implement them, I will make sure that they will
> 1) be more accurate than can currently be expected on many platforms
> 2) produce the same results on all platforms.

Actually, close enough is almost invariably good enough for these operations.

With any compiler worth talking about your discrepancies will fall into two
categories:

1) Different ways of handling overflow, underflow, etc.

DGD should catch these and do something standard in each case, e.g. issue
an error() for an overflow.

2) Differences in the last digit of the result.

Irrelevant unless you are doing something inappropriate -- which is going to
get you into trouble anyway.

Unless you aim to implement an arbitrary precision type I personally believe
you are chasing your tail somewhat, even though your aims are noble.

Out of curiousity, does anyone know how Java handles these functions in its
Math class?

-- 
Greg Lewis                              Applied Maths Department
Email : glewis at maths.adelaide.edu.au    University of Adelaide
--
Teach children to be polite and courteous in the home, and, when he
grows up, he will never be able to edge his car onto a freeway.



List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list