http://www.microsoft.com/technet/script ... y1019.mspx
As described in there (no, i am not Jo) i'm trying to work with odd and even numbers. If anyone knows another alternative, do tell!
Thanks for reading.
What is "Mod" in PB? *solved*
What is "Mod" in PB? *solved*
Last edited by CadeX on Fri Mar 02, 2007 9:51 am, edited 1 time in total.
Pro-Gamer, Programmer, Pro-Grammer
Code: Select all
NumberToTest.l = 15
NumberToTest % 2
http://www.purearea.net/pb/english/manu ... ables.html
scroll to the bottom.
Last edited by Kale on Fri Mar 02, 2007 9:51 am, edited 2 times in total.
Re: What is "Mod" in PB? *solved*
Use % where you see Mod in other Basics. So, for the URL you quoted, do this:
Code: Select all
a = 13
intResult = a % 2
If intResult = 0
Debug "This is an even number."
ElseIf intResult = 1
Debug "This is an odd number."
Else
Debug "This does not appear to be a whole number."
EndIf
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
hint:
% is quite slow.
since this all is about Integers, you can also test bit 0 to determine odd or even:
Demo:
% is quite slow.
since this all is about Integers, you can also test bit 0 to determine odd or even:
Code: Select all
Odd = Value & 1
Code: Select all
For attepts = 1 To 100
Value = Random(999999999)-500000000
; ****
Odd = Value & 1
; ****
If Odd
Gen$ = "odd"
Else
Gen$ = "even"
EndIf
Debug Str(Value) +" is "+Gen$
Next
oh... and have a nice day.