isinf

function isinf( x ) --> res

Description

Returns whether x is an infinity value (either positive infinity or negative infinity).

Parameters

x

The number that should be checked.

Return Values

res

true if x is an infinity, otherwise false.

Code

--ZFUNC-isinf-v1
local function isinf( x ) --> res
   return x == math.huge or x == -math.huge
end

return isinf

Examples

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

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

t()