lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 12/10/2011 12:20 AM, Roberto Ierusalimschy wrote:
and the simple tests:

  print(2^3 - 8)
-1.7763568394003e-015
  print(3^4 - 81)
2.8421709430404e-014
=2^4-16
-1.7763568394003e-015

These all should be zero. It really seems that the 'pow' function
from the C library is broken.

Correction to my previous post, usage of 2 ** (y log2(x)) for x86 may not be the real reason. For one, the value I got (-2.84217e-014) had the wrong sign, and secondly, for 2^3-8, the calculation is exact.

FWIW, for the result -2.84217e-014, the IEEE754 double byte value of the 81-something value versus the normally expected result is:

0x40543FFFFFFFFFFF => short of -2.84217e-014
0x4054400000000000 => 81 exact

so Tymur's result should be off by 1 in the other direction,
0x4054400000000001

Sorry for the noise. But a non-exact value for 2^3-8 seems pretty bad for business, though...

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia