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.
Does SpiderBasic have a way to find out if a variable's value is odd or even?
- Random Terrain
- Posts: 63
- Joined: Fri Jul 09, 2021 9:48 pm
- Location: USA
- Contact:
- 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?
Maybe this is the answer?
Code: Select all
If variable % 2 = 0
Debug "Even Number"
EndIf
- 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?
In case anyone wants to know, it seems to be working.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
You'd use this to find out if it's an odd number:
Code: Select all
If variable % 2 = 1
Debug "Odd Number"
EndIf