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 ImageImage
B
171
S
50
G
180
Posts: 8,396
Reputation: 113,986

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
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

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 ImageImage
B
171
S
50
G
180
Posts: 8,396
Reputation: 113,986


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 3 guests