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( "taptest" )
local iseven = require( "iseven" )

t( iseven( 98 ), true )
t( iseven( 2 ), true )
t( iseven( 0 ), true )
t( iseven( -4 ), true )

t( iseven( 99 ), false )
t( iseven( 1 ), false )
t( iseven( -3 ), false )

t( iseven( 7.3 ), false )

t()