[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: NaN in Lua 5.3 Reference Manual
- From: Martin <eden_martin_fuhrspam@...>
- Date: Fri, 23 Jun 2017 21:17:29 -0700
On 06/23/2017 10:04 AM, John Hind wrote:
> [...] What about positive and
> negative zero? Would these be distinguished table keys?
With positive and negative float zeros is funny thing: you can't (I
don't know how) distinguish negative float zero (-0.0) from positive
float zero (0.0). Usually we detect negative number by comparing it with
0, which is not applicable here.
But in tables both three zeros as key maps to integer zero:
Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio
> t = {[0] = '0', [0.0] = '0.0', [-0.0] = '-0.0'}
> for k, v in pairs(t) do print(math.type(k), k, v) end
integer 0 -0.0
-- Martin