[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 10:36:30 +0200
On Sun, Feb 20, 2011 at 07:53:53PM +0200, Francesco Abbate wrote:
>
> I have a very simple question. The default behaviour of Lua when a FP
> error is encountered is to not raise any error and set the result to
> NaN or Inf.
>
Don't pick on Lua. Specialized numerical analysis languages like
Octave do it too.
> I found this behaviour quite unconvenient for numerical procedures
> when it is better to raise a (Lua) error as soon as the problem
> happens.
>
Most others find it convenient. That's why it's the default behaviour.
> It is possible to easily modify Lua and/or LuaJIT2 for this purpose ?
>
Define "easily". It's certainly possible.
But the Lua way is to show the test for NaN explicitly your code.
http://snippets.luacode.org/snippets/Test_for_NaN_75
Dirk