evaluating ODD/EVEN properties of integers

# Thread: evaluating ODD/EVEN properties of integers

1. Senior Member
Join Date
Dec 1969
Posts
395

## evaluating ODD/EVEN properties of integers

Is there an operator in ASP which can evaluate a number and determine whether or not that number is ODD or EVEN? If so, what is it?<BR><BR>I&#039m trying to build a little randomizer that will return different results based upon whether the second in the current time is odd or even.

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

## RE: evaluating ODD/EVEN properties of integers

Hi<BR><BR>i was trying to do the same thing and i didn&#039t ever find a result..<BR><BR>i think what we have to do is to write a little function or something and do a little math...<BR><BR>i will think and if i everfigure it out i&#039ll maybe post it somewhere..<BR><BR>peace

3. peterjl@austec.net.au Guest

## RE: evaluating ODD/EVEN properties of integers

A function like this would do the trick:<BR><BR>&#060;%<BR>function IsOdd(n)<BR>&nbsp;&nbsp;&nbsp;&nbsp;IsOdd = ((n Mod 2)=1)<BR>end function<BR>%&#062;<BR><BR>The function IsOdd would return true is the number is odd, and false if it is even.<BR><BR>I terms of your &#039little randomizer&#039, though, you probably want something like this:<BR><BR>&#060;%<BR>function Altern(Val1, Val2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;Randomize<BR>&nbs p;&nbsp;&nbsp;&nbsp;Altern = array(Val1,Val2)(int(Rnd * 2))<BR>end function<BR>%&#062;<BR>

4. shaffer Guest

## RE: evaluating ODD/EVEN properties of integers

Actually, there are several ways. Here are three:<BR><BR>Method #1:<BR><BR> if intRandom mod 2 = 0 then response.write "Is Even"<BR><BR>Method #2:<BR><BR> if (intRandom / 2) = (intRandom 2) then response.write "Is Even"<BR><BR>Method #3:<BR><BR> if (intRandom AND 1)=0 then response.write "Is Even"<BR><BR><BR> - Mike<BR><BR>

#### Posting Permissions

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