Suggestion: # is even, or odd for expressions

New releases and general discussions.

Post » Mon Nov 16, 2009 4:39 pm

Um yeah thought it might be nice to be able to pick based on whether a number is even or odd.
Unless there's some simple way I'm just not seeing.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Mon Nov 16, 2009 5:17 pm

You can check if a number is odd or even by using the modulo(%) operator. Since the modulo operator finds the remainder of division, if n % 2 = 0, the number is even.
Moderator
B
98
S
36
G
19
Posts: 1,584
Reputation: 17,717

Post » Mon Nov 16, 2009 11:31 pm

Ok, well that's simple enough. :D

First I thought zeropad would give me to the ones position, and I could just compare to 2,4,6,8,0, strangely enough zeropad only pads with zero's... imagine that.

I even thought of using len and then converting it back and forth from a string. :mrgreen:

Thanks
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 3 guests