isfinite

function isfinite( x ) --> res

Description

Returns whether x is a finite value.

Parameters

x

The number that should be checked.

Return Values

res

true if x is a finite, otherwise false.

Code

--ZFUNC-isfinite-v1
local function isfinite( x ) --> res
   return x > -math.huge and x < math.huge
end

return isfinite

Examples

local t = require( "tapered" )
local isfinite = require( "isfinite" )

t.ok( isfinite( 0.0 ) )
t.nok( isfinite( 1.0 / 0.0 ) )
t.nok( isfinite( -1.0 / 0.0 ) )
t.nok( isfinite( math.sqrt( -1.0 ) ) )

t.done()