Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
This is not a problem...anymore. But it was interesting enough that I thought I'd mention it.
A member of my team came to me with a piece of Rexx. An IF statement that compared two account numbers was failing inexplicably; although the account numbers were obviously different, the comparison was returning "true".
After staring at the code and the trace longer than I'm willing to admit, the answer stuck me: the account numbers were composed all of decimal digits, so as far as a typeless language like Rexx was concerned, they really were numbers. The default number of significant digits in TSO REXX is nine...and the differences were all to the right of the ninth digit.
I advised him to either increase the number of significant digits with the NUMERIC DIGITS statement, or to use the built-in COMPARE function, which always does a character comparison on its first two arguments, even though they be numeric. |
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
This is just as interesting, a looping compare:
Code: |
/* REXX exec to demonstrate funny compare behaviour */
a = '2e0'
b = '2ee'
c = '1e1'
say "a =" a
say "b =" b
say "c =" c
if a > b then say 'a > b' else say 'a ^> b'
if b > c then say 'b > c' else say 'b ^> c'
if c > a then say 'c > a' else say 'c ^> a' |
|
|