Odd or even

1. Tom
Senior Member
Join Date
Dec 1969
Posts
730

## Odd or even

How can I tell if a number is odd or even - Isnumeric tells you if its a number but that number could be 2.423 <BR>I may divide the variable by 2 ie and see if it contains a dot.<BR><BR>ie if instr(mynumber2,".") then it must be odd as long as mynumber is not 1 <BR><BR>hmmm Im thinking aloud and may have solved my own problem!!!!!<BR>Is there a function that does this anyway though <BR>Peace <BR>

2. Senior Member
Join Date
Dec 1969
Posts
1,435

## RE: Odd or even

It&#039s better to use the Mod operator (which divides one number by another and returns the remainder) because it just uses simple arithmetic:<BR><BR>If myNumber Mod 2 = 0 Then &#039must be even<BR><BR>Dunc

3. BalletChick Guest

## RE: Odd or even

Here&#039s an even faster way... assuming that intX is the integer you want to test for even/odd-ness:<BR><BR>&nbsp;&nbsp;&nbsp;evenodd = (intX and 1)<BR>

4. Senior Member
Join Date
Dec 1969
Posts
1,435

## RE: Odd or even

Nice! I&#039ll have to remember that.<BR><BR>Dunc

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•