# Is there a simple method to determine Odd/Even Integers?

## Recommended Posts

Is there a simple way to determine if a number is odd or even? PASCAL math commands include ODD(x), but this appears missing from Vectorscript.

I tried ODD anyway, and got this error.

[font:Courier New] if ODD(wLights) then [do some stuff based on wLights];

|

{ Error: Identifier not declared. }

|

{ Error: Expected a string. }

|

{ Error: Expected a Boolean. }

|

{ Error: Did not expect this after end of statement - missing ;? }

[/font]

Alternately, is there perhaps a way to determine factors? I could simply check if a number is divisible by 2 or 3...

I might be missing something obvious, but I have honestly been scouring the language guide and the developer reference. I appreciate any ideas!

Have you tried

Test := X MOD 2;

IF Test = 0

THEN {do even number stuff}

ELSE {do odd numbered stuff}

mk

I have not! because I do not recognize that command, X MOD 2;

I can't find that in the guide... may I trouble you foe either a link or an explanation?

Thanks!

mod is technically an operator, and a common programming method:

Boom! perfect. Thank you both very much!

(just had to make sure wLights was INTEGER... MOD won't take REAL.)

[font:Courier New]Test := wLights MOD 2;

IF Test = 0

THEN

begin

{do even number stuff}

end

ELSE

begin

{do odd numbered stuff}

end;

[/font]

Just for future reference, all of the Operators (mathematical and boolean) are described in the Vectorscript Language Guide that is part of the VW Help.

That information should probably also be in either the Function Reference or the Appendices.

Excellent point, Mr Stanford, but I must confess I would not have known to look for MOD regardless of its presence. When I post, it is as much for programming advice as for bibliographic reference?I apologize if that is a misuse of the forum.

?

AE,

Perfectly legitimate use of the forum.

I posted this for my reference as much as yours. I have spent many hours looking in the Function Reference before remembering it is considered an "Operator" rather than a "Function" or "Procedure".

I have filed an enhancement request to get it all pulled together in one place.

## Create an account

Register a new account