iseven

function iseven( num ) --> res

Description

Checks if the number num is even or odd.

Parameters

num

The number that is checked.

Return Values

res

Returns true if the number is even, otherwise false.

Code

--ZFUNC-iseven-v1
local function iseven( num ) --> res
   return math.fmod( num, 2 ) == 0
end

return iseven

Examples

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

t.ok( iseven( 98 ) )
t.ok( iseven( 2 ) )
t.ok( iseven( 0 ) )
t.ok( iseven( -4 ) )

t.nok( iseven( 99 ) )
t.nok( iseven( 1 ) )
t.nok( iseven( -3 ) )

t.nok( iseven( 7.3 ) )

t.done()