Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Odd or Even


Recommended Posts

I don't know if Lua does integer math but you can divide the number by 2 then multiply it back by 2 and see if it becomes the same number.  In C it looks like this:

if ((n/2)*2 == n)
      printf("Even\n");
   else
      printf("Odd\n");

For example, 7 divided by 2 would become 3 (because 3.5 becomes 3 when it's an integer) and would then double to 6.  Since 7 doesn't equal 6, you know it was an odd number.

(Credit: https://www.programmingsimplified.com/c/source-code/c-program-check-odd-even)

 

Link to post

Thanks Catch and GC for the help.

Turns out that Leadwerks does recognize the % as  modulo.

So if  X%2  equals 0 then its an even number and

if X%2 does not equal 0 its an odd number. 

Changing the 2 to other numbers will be true if the x is a multiple of that number.

Now back to making a hex map.

20190511173628_1.thumb.jpg.b8c3b74d34e603776707b055a6bc5a22.jpg

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Facebook Twitter Youtube Github Steam
×
×
  • Create New...