Prev Next even

Determining if an Input is Even-valued
Syntax y = even(x)
Include: include spt\even.oms
See Also

ARGUMENTS:
   INPUTS:
      x = MATRIX, any numerical type, elements not to exceed
          INT_MAX.
   RETURN: MATRIX, integer type, '1' if even. '0' otherwise.

Description

Determines, on an element-by-element basis, whether input is an even number. Converts a numerical input matrix to an integer matrix where each element is '1' if original was even, or '0' if original was odd. Input matrix may be any numerical type. Non-integer input is coerced to 'integer' before local processing. Input values may not exceed INT_MAX without error.

Example

O>[seq(10), even(seq(10))]
{
[ 1 , 0 ]
[ 2 , 1 ]
[ 3 , 0 ]
[ 4 , 1 ]
[ 5 , 0 ]
[ 6 , 1 ]
[ 7 , 0 ]
[ 8 , 1 ]
[ 9 , 0 ]
[ 10 , 1 ]
}