lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sat, Nov 6, 2010 at 08:08, Mike McGonagle <mjmogo@gmail.com> wrote:
> Hi all,
>
> I have been trying to determine how to do this in Lua. I am working on
> some Chaotic Attractors, and as such, I need to be able to detect when
> a number is "NaN" as a result of these functions, but I can't quite
> seem to find exactly how this is done in Lua... one thing that I found
> was the following, but I am not certain if this is the "accepted" way,
> as one comment said it was not necessarily portable...
>
> if x ~= x then
>     -- x is NaN, as if a number is NaN, it will always return false
> when being compared.
> end
>
> Not trying to dredge up this topic again, but I can't quite seem to
> find the "definitive" method of making this test. Currently my
> programs are just throwing errors and stopping, I would like to be
> able to detect when this happens, discard the results, and then move
> on to the next iteration of my program.
>
> Any pointers to where this is discussed in full (I have already seen
> http://lua-users.org/wiki/InfAndNanComparisons but this doesn't seem
> to give a definitive solution.).
>
> Thank,
>
> Mike
>
>

tostring(n)? Though I'm seeing "-nan" for 0/0.

-- 
Sent from my toaster.