|
On Feb 27, 2005, at 01:36, Luiz Henrique de Figueiredo wrote:
1) Add 'math.nan' as a constant to the math library. At the moment, the"feature" of doing local nan = tonumber("nan")works, but is inconvenient, probably non portable and hard to remember.A more portable solution is something like "nan = math.sqrt(-1)", but that relies on IEEE 754. Perhaps an IEEE 754 library would be a goodidea (I have a draft of one but it's not complete and it's not portable,not even among platforms that claim to be IEEE 754. C99 helps here but it's not widespread yet.)
nan = tonumber"nan" will do, it's not very non-portable. On an IEEE conforming system this will generate a NaN. On systems without NaNs then it will generate 0. Seems like a reasonable behaviour. You can even do [[ if nan == nan ]] to see which one you ended up with.
Why would anyone anyone want math.nan anyhow? Surely they get generated naturally as the result of ordinary computation.
David Jones