isnan

function isnan( x ) --> res

Description

Returns whether x is a NaN(Not-a-Number) value.

Parameters

x

The number that should be checked.

Return Values

res

true if x is a NaN value, otherwise false.

Code

--ZFUNC-isnan-v1
local function isnan( x ) --> res
   return x ~= x
end

return isnan

Examples

local t = require( "taptest" )
local isnan = require( "isnan" )

t( isnan( 0.0 ), false )
t( isnan( 1.0 / 0.0 ), false )
t( isnan( -1.0 / 0.0 ), false )
t( isnan( math.sqrt( -1.0 ) ), true )

t()