check if a number is a multiple of 2 (EVEN)

mirage's icon

can i make an else if statement that can check if a number is a multiple of 2 in other words (EVEN)

what i was thinking was something like this:-

if $i1 =/ 2 then out1 $i1 else out2 $i1

any help would be great i feel like i'm overlooking a simple solution.

many thanks in advance.

MiRAGE

kjelgaard's icon

use modulo. [ if $i1 % 2 == 1 then odd else even ]

metamax's icon

mod 2 of the absolute value of an integer is 0 if it's even and 1 if it's odd.

Max Patch
Copy patch and select New From Clipboard in Max.

Christopher Dobrian's icon

[& 1] is 0 if even, 1 if odd