# Telling if Odd or Even

• KRC4
WV - V3.1.8_Build22

So I know in most coding the "%" operator is used to tell if there is a remainder when 2 numbers are divided. Normally I use this operation:
Count % 2 <> 0 ; ODD
Count % 2 == 0; EVEN

Is there an operator like this in KRL?
Here is an outline of what I am trying to acomplish:

I know about variable deceleration, and currently these are all declared as INT's

Does anybody have a way or an operation to determine if a variable value is ODD or EVEN?

• Easy enough, using the way that KRL truncates certain INT/REAL conversions:

Code
``````IF ((Integer/2) <> (Integer/2.0)) THEN
;odd
ELSE
;even
ENDIF``````
• Damn so simple, yet I overlooked it.
One of these days I wont overlook the obvious lol

Thank you

• or just do what you suggested yourselves

Code
``````DEFFCT BOOL Even(N:in)
DECL INT N
RETURN (N B_AND 1)==0
ENDFCT``````

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

• yep... the simplest and fastest option is to just evaluate LSB

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly