[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Automatic string <> number conversion, what about INF, NaN?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 13 Dec 2002 09:50:47 +0000
> Lua and its API (lua_tostring() lua_tonumber()) does automatic
> conversion between numbers and strings representing numbers.
> This symmetry seems to be broken for special floating point
> values representing +/- infinity or various "not a numbers".
> [...]
> Why?
Lua uses C to do the conversions (sprintf/strtod). In my system, your
code runs as you expect:
> infinity = 1/0
> print(infinity)
inf
> print(math.sin(infinity))
nan
> print(math.sin("inf"))
nan
But it seems that not all C implementations do that...
-- Roberto