[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Some small requests for the next release
- From: Luis Carvalho <carvalho@...>
- Date: Mon, 28 Feb 2005 12:14:00 -0500
On Mon, Feb 28, 2005 at 01:45:51PM +0000, David Jones wrote:
<snip>
> 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.
<snip>
If you really want math.nan (and math.inf, for that matter), you can define
math.nan = 0/0 and math.inf = 1/0. But I think that
math.isnan = function(x) return not (x==x) end
math.isinf = function(x) return math.isnan(x-x) end
would be more useful. If you deal with a lot of computations (numerical
analysts, unite!), you can wrap those in a library (HUGE_VAL for inf, isinf,
isnan...). But then you'd be better off doing computations on C and wrapping
your results to lua.
Cheers,
--luis, two cents more, please.
--
A mathematician is a device for turning coffee into theorems.
-- P. Erdos
--
Luis Carvalho
Applied Math PhD Student - Brown University
PGP Key: E820854A <carvalho@dam.brown.edu>