
2009/8/22 Roberto López
If 4.0 / 2.0 was 1.9999999999999999999998, it would be ok?
I think yes. However, hardware can afford to do computations "as accurately as possible", whereas software like Haskell Prelude can't.
The real value of log10 1000 is 3 (3.0). It can be represented with accuracy and it should be.
Doing so would not be of much use and would impose a performance penalty required to achieve this accuracy. I looked into the Prelude source and saw that logBase is implemented like x`logBase`y = log x / log y. I think it is quite a sensible definition, and there's no point in modifying it just to make accuracy even better than 0.000000000000000004 in certain cases where it is possible. To my mind, an accuracy of "the representable number closest to the exact answer" is only required in very specific circumstances, for example when you are converting a string to a float. If you have a good reason to need exact real numbers, you can use a corresponding package for exact reals. However, if you propose an equivalently fast definition of logBase that achieves better accuracy, I am sure it will be much welcomed.
You get the accuracy value in Perl, but there is the same problem in Python. It's a bit discouraging.
Eugene Kirpichov wrote:
What do you consider to be the specification of logBase? Exact floating-point numbers don't exist, so it has to return an approximation. The standard doesn't give any guarantees as to the precision of the approximation. Is a precision of 0.00000000000004 not satisfactory for you?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Eugene Kirpichov Web IR developer, market.yandex.ru