
1. Re: Test for odd or even integers
LaRetta Mar 27, 2013 4:59 PM (in response to youngge)Mod() is what you seek ...
For example, to know if the record number is odd:
Mod ( Get ( RecordNumber ) ; 2 )
... and even would be:
not Mod ( Get ( RecordNumber ) ; 2 )
... replacing the blue with any number or calculation.

2. Re: Test for odd or even integers
taylorsharpe Mar 27, 2013 5:11 PM (in response to LaRetta)Mod is the smart math person's way of doing things and I'm sure LaRetta is much smarter than me. Simpler people from Texas, like me, do things like:
If ( <some number> / 2 = Int ( <some number> / 2 ) ; "Even" ; "Odd" )
fyi, "Int" is short for integer and if you have a number like 8.9283749283, it chops off the decimals and leaves you just with the Integer of 8.
This makes sense to me because
4/2 = Int ( 4/2 ) 2 = 2
where as
3/2 ≠ Int ( 3/2 ) 1.5 ≠ 1
But I have to admit, it would be nice if this was just a function like in Excel.

3. Re: Test for odd or even integers
keywords Mar 27, 2013 5:17 PM (in response to youngge)Mod ( ) using the divisor 2 will result in a 1 for odd numbers (ie. a modulus exists) and a 0 for odd numbers (ie. there is no modulus because the number is divisble by 2). As it is a boolean result you can set it to display the words "odd" and "even" if you wish, or incorporate this result into an If ( ) calc function.

4. Re: Test for odd or even integers
Vaughan Mar 27, 2013 8:51 PM (in response to keywords)To be pedantic, Mod() does not return a boolean result. It returns a number. For the case when the divisor is 2 the results may be interpreted as boolean true or false but this is a special case, and not a generally valid interpretation.
Mod( 1 ; 2 ) is not returning boolean true, it's returning 1
Mod( 2 ; 2 ) is not returning boolean false, it's returning 0
Mod( 7 ; 5 ) is returning 2

5. Re: Test for odd or even integers
LaRetta Mar 27, 2013 9:17 PM (in response to Vaughan)Hi Vaughan!
Vaughan said, " Mod( 1 ; 2 ) is not returning boolean true, it's returning 1"
Stop ... you're both right ... it can be a floor wax AND a dessert topping. ( that's an old Saturday Night Live ) ...
No, it does not return just 1 or 0  good clarification  it returns the number result of its evaluation. But, and you know this so just clarifying for others who may be confused about now, all characters/data produces boolean result always whether it likes it or not. Dates are always boolean true whereas text fields without numbers are always boolean false  the boolean is a state of being more than a result. Any number but 0 produces true (1).
But mainly I wanted to use the Saturday Night Live saying and say hi to you  nice connecting with you over in these parts!

6. Re: Test for odd or even integers
keywords Mar 28, 2013 12:15 AM (in response to LaRetta)Fair points, both of you. Perhaps I should have written "As it is LIKE a boolean result…" to be more accurate. Dividing by 2 is, as Vaughan noted, a special case which, with whole numbers will I believe give only a 0 or 1.

7. Re: Test for odd or even integers
youngge Mar 28, 2013 3:57 PM (in response to LaRetta)Thank you LaRetta. Exactly what I need (and thanks to all other responders). It's obvious when you see it. It's been a long time since I've used this function.

8. Re: Test for odd or even integers
LaRetta Mar 28, 2013 11:25 PM (in response to keywords)Keywords said, "Perhaps I should have written "As it is LIKE a boolean result…" to be more accurate. "
LOL, You had it right the first time; no 'like' about it ... it PRODUCES number result and it IS a Boolean ... whether 1 or 0 ... everything is.