[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: tostring vs. nan, inf
- From: Jose Torre-Bueno <jtorrebueno@...>
- Date: Thu, 12 Apr 2012 08:26:19 -0700
But I notice nan cannot be assigned to a variable, the variable is set to nil.
> c = nan
> =isnan(c)
false
> =c
nil
but a variable with nan as its value can set another variable to nan:
> a = 0/0
> = isnan(a)
true
> c = a
> = c
nan
further two variables set to nan are not equal to each other:
> a = 0/0
> b = 0/0
> = a==b
false
But nan is equal to itself:
> = nan == nan
true
> = nan
nil
>
this says to me that nan is not a pseudo constant in the same way nil is. I assume there is something subtle going on here. Perhaps somebody can explain why this is so.
On Apr 10, 2012, at 5:38 AM, Luiz Henrique de Figueiredo wrote:
>> but I don't see how to detect nan portably.
>
> function isnan(x) return x~=x end
> function isinf(x) return (x+1)==x end
>
> See http://lua-users.org/lists/lua-l/2005-02/msg00758.html for alternatives
> and my lmathx for a C implementation:
> http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lmathx
>
- References:
- tostring vs. nan, inf, Alexander Gladysh
- Re: tostring vs. nan, inf, Luiz Henrique de Figueiredo
- Re: tostring vs. nan, inf, Alexander Gladysh
- Re: tostring vs. nan, inf, Martin Guy
- Re: tostring vs. nan, inf, Luiz Henrique de Figueiredo