Does SpiderBasic have a way to find out if a variable's value is odd or even?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Random Terrain
Posts: 63
Joined: Fri Jul 09, 2021 9:48 pm
Location: USA
Contact:

Does SpiderBasic have a way to find out if a variable's value is odd or even?

Post by Random Terrain »

In another BASIC-like language I use, all you have to do is check bit 0. If bit 0 is on, the number is odd.

I've been searching the SpiderBasic info and so far can't find anything on the subject.


Thanks.
User avatar
Random Terrain
Posts: 63
Joined: Fri Jul 09, 2021 9:48 pm
Location: USA
Contact:

Re: Does SpiderBasic have a way to find out if a variable's value is odd or even?

Post by Random Terrain »

Maybe this is the answer?

Code: Select all

If variable % 2 = 0
Debug "Even Number"
EndIf
User avatar
Random Terrain
Posts: 63
Joined: Fri Jul 09, 2021 9:48 pm
Location: USA
Contact:

Re: Does SpiderBasic have a way to find out if a variable's value is odd or even?

Post by Random Terrain »

Random Terrain wrote: Mon Aug 02, 2021 7:03 am Maybe this is the answer?

Code: Select all

If variable % 2 = 0
Debug "Even Number"
EndIf
In case anyone wants to know, it seems to be working.

You'd use this to find out if it's an odd number:

Code: Select all

If variable % 2 = 1
Debug "Odd Number"
EndIf
Post Reply