lua-users home
lua-l archive

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


On 9/20/2010 12:45 AM, Mike McGonagle wrote:
I am running on a Mac OS X 10.4.11 with lua 5.1.2, comiled in 2007.

here are the first few lines of output...

i:0.000000 r:0.000000 c:-0.000000 b:0.000000 br:-0.000000 bc:-0.000000
i:1.000000 r:0.000000 c:1.000000 b:0.000000 br:-0.000000 bc:1.000000
i:2.000000 r:0.000000 c:2.000000 b:0.000000 br:-0.000000 bc:2.000000
i:3.000000 r:0.000000 c:3.000000 b:1.000000 br:-0.000000 bc:-0.000000
i:4.000000 r:0.000000 c:4.000000 b:1.000000 br:-0.000000 bc:1.000000
i:5.000000 r:0.000000 c:5.000000 b:1.000000 br:-0.000000 bc:2.000000
i:6.000000 r:0.000000 c:6.000000 b:2.000000 br:-0.000000 bc:-0.000000
i:7.000000 r:0.000000 c:7.000000 b:2.000000 br:-0.000000 bc:1.000000
i:8.000000 r:0.000000 c:8.000000 b:2.000000 br:-0.000000 bc:2.000000
i:9.000000 r:1.000000 c:-0.000000 b:0.000000 br:1.000000 bc:-0.000000

As you notice, not all the 0's are negative. I don't know, maybe this
really isn't an issue, as so far I have not run into anything other
than this output being not exactly what I expect. I do know that I
have a later version of lua on my machine, but I don't really have the
time at the moment to check it... so maybe I should just try that and
then get back to the list...

It looked too regular to me, so I checked some references -- the following may help:

From IEEE-754 (Q754.129 draft, page 49):

8.3 The sign bit

When the sum of two operands with opposite signs (or the difference of two operands with like signs) is exactly zero, the sign of that sum (or difference) shall be +0 in all rounding direction modes except roundTowardNegative; in that mode, the sign of an exact zero sum (or difference) shall be –0. However, x+x = x–(–x) retains the same sign as x even when x is zero.

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