lua-users home
lua-l archive

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


On 5 June 2011 12:31, Dirk Laurie <dpl@sun.ac.za> wrote:
> On Sun, Jun 05, 2011 at 12:47:39PM +0200, Sebastian wrote:
>> I have found an interesting bug. if you run
>>
>> a = 0
>> b = -0
>> if (a == b) then
>> print("0 is -0!")
>> end
>>
>> in the lua demo (http://www.lua.org/cgi-bin/demo), then you see that lua
>> does'nt make a difference between 0 and -0.
>
> This is not a Lua bug.  It is not any kind of bug.  It is defined this
> way in the IEEE 754 floating-point standard:
>    http://en.wikipedia.org/wiki/Negative_zero

Indeed, there's no bug here. Further, it's worth pointing out that
unlike some languages, Lua relies on the C compiler and underlying
hardware directly for arithmetic operations, just as it relies on the
compiler and system libraries for I/O. Hence, if you suspect a bug
that is not directly related to the language itself, the first place
to look is usually the appropriate part of the underlying system.

-- 
http://rrt.sc3d.org