Even or Odd numbers

Dave312

Censored for your safe viewing
Reaction score
269
Just get the remainder after dividing by 2 (modulus I think it's called). If 0, then the number is even. If 1, the number is odd.
 

Ayanami

칼리
Reaction score
288
There is one way. Since all reals are rounded down when converted to integers, you can do this. Let's say TempReal is the number that you want to find out if its even or odd. TempReal is a real variable. TempInteger is an integer variable.

Trigger:
  • Actions
    • Set TempReal = 5.00
    • Set TempInteger = (5 / 2)
    • Set TempReal = ((TempReal / 2.00) - (Real(TempInteger)))


This will actually leave you with TempReal = 0.50. Now let's see for an even number case.

Trigger:
  • Actions
    • Set TempReal = 6.00
    • Set TempInteger = (6 / 2)
    • Set TempReal = ((TempReal / 2.00) - (Real(TempInteger)))


This would leave you with TempReal = 0.00. Thus, you can use this to check.

Trigger:
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • TempReal Equal to 0.50
      • Then - Actions
        • Number is odd. Your actions here.
      • Else - Actions
        • Number is even. Your actions here.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top