# Even / Odd Number Determination

Determine if a number is odd or even using 3 different methods

This sample task will demonstrate how Automate can determine if a number is odd or even using 3 different methods.

Determining if a number is odd or even can be done in various ways. You could divide the number by 2 and see if there is a fraction remaining or you could use the MOD function. Either way you are performing an operation that is quite heavy for the processor (in comparison to a bitwise AND operation). Method #1 is the fastest method.

1. %(varNum AND 1)% <> 0
The bitwise AND operator performs a bitwise comparison against the number you want to test. The result is either a 0 or 1 -- 1 for odd numbers, and 0 for even numbers.

2. %(varNum mod 2)% <> 0
The MOD operator divides two numbers and returns only the remainder. Given that all odd numbers return a 1 when divided by 2, you can simply test for this result.

3. %int(varNum/2)% = %(varNum/2)%
The INT function returns the integer part of a specified number. In other words, it returns the largest integer which is less than or equal to this numeric value. For example, if varNum is 7 then it looks like 3 = 3.5 and if varNum is 6 then it looks like 3 = 3. The INT function strips off any remainders and therefore makes the equation fail if the number is an odd number.