Rexx Programming/How to Rexx/numeric comparison

From Wikibooks, open books for an open world
Jump to: navigation, search

The following example shows a numerical comparison being using comparative operators:

x = 3 if x > 2 then

 say "x is greater than 2"

Supported operators[edit]

The following comparative operators are supported:

=  Equal To
\=      Not Equal To
<    Less Than
>    Greater Than
<=   Less Than or Equal To
>=   Greater Than or Equal To
\<   Not Less Than
\>   Not Greater Than
<>        Not Equal To
><        Not Equal To

Leading zeros are ignored for numerical comparisons[edit]

For a numerical comparison to be made, leading zeros are ignored:

x = "002"
if x = 2 then
  say "x equals 2"

Leading and trailing whitespace is ignored for numerical comparisons[edit]

y = " 10 "
if y = 10 then
  say "y equals 10"