01-18-2006, 06:56 AM
Hybr!d, If you dont understand the MOD method, you could try this little one:
[syntax="qbasic"]if number / 2 = number \ 2 then #its even!# else #its odd!#[/syntax]
Basically it checks if the number / 2 is a whole number by comparing it to the equivalent integer calculation (which is always rounded to the nearest whole number). If the number is even, both calculations will produce the same result, however if the number is odd, the floating point divide will produce non-whole number and the integer division will produce a whole number and they wont match.
[syntax="qbasic"]if number / 2 = number \ 2 then #its even!# else #its odd!#[/syntax]
Basically it checks if the number / 2 is a whole number by comparing it to the equivalent integer calculation (which is always rounded to the nearest whole number). If the number is even, both calculations will produce the same result, however if the number is odd, the floating point divide will produce non-whole number and the integer division will produce a whole number and they wont match.