Forums > MaxMSP

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

February 10, 2014 | 6:23 pm

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


February 10, 2014 | 6:37 pm

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


February 10, 2014 | 6:58 pm

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

– Pasted Max Patch, click to expand. –

February 10, 2014 | 10:18 pm

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


Viewing 4 posts - 1 through 4 (of 4 total)