[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: NaNs etc. once again. Was: Re: 5.1 and vc6
- From: Rici Lake <lua@...>
- Date: Sun, 6 Mar 2005 21:46:26 -0500
On 6-Mar-05, at 9:32 PM, Mark Hamburg wrote:
I think one could separate the issues of whether NaN tests false in a
conditional context from what it does in an assert.
Indeed. And one could use math.isnan (if there were such a thing) to
test for NaNs (if the architecture had such things).
x = math.sqrt(math.atan(theta))
if not x then
-- oops an error
seems easier to explain and understand than either:
if x ~= x then ..
if math.isnan(x) then ...
And it seems slightly more consistent with other Lua functions which
return false, <error> on error. There would be nothing stopping
math.sqrt(-1) from returning:
NaN, "square roots of negative numbers are a complex subject"
although that would be trickier with 0 / 0 and 0 * infinity