lua-users home
lua-l archive

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


On Sun, Jun 5, 2011 at 7:31 AM, 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

This basically. Also patching tostring is pointless because of:

batrick@menzoberranzan:~$ lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> print("a"..-0)
a-0

I seriously doubt the Lua authors would insert a check for -0 making
the common case incredibly slow to appease the people who can't
understand floating point arithmetic.

-- 
- Patrick Donnelly