[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: simple question about NaN and FP exceptions
- From: Dirk Laurie <dpl@...>
- Date: Mon, 21 Feb 2011 23:37:18 +0200
On Mon, Feb 21, 2011 at 06:54:44PM +0200, Steve Litt wrote:
>
> Wouldn't that break existing code that assumes only false and nil are false?
>
Show me that code. I don't mean quickly invent some, I mean exhibit
some Lua code already published.
IMHO, Axel's suggestion that NaN should be considered false is by far
the best idea I've seen on this list since 5.2 was announced.
(a) NaN is to numbers what nil is to Lua values: not-a-number vs
not-a-value. It makes intuitive sense that it should be logically
different from numbers.
(b) The implementation, as Tony has shown, requires a minimal
change to the Lua source code.
(c) It would allow elegant error-checking code like
x=assert(x-f(x)/df(x), "NaN in Newton iteration, maybe a multiple zero?")
Dirk