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?

  • or just do what you suggested yourselves



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

    1) read pinned topic: READ FIRST...

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

    3) read 1 and 2

Advertising from our partners