Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

REXX Math large numbers

Status
Not open for further replies.

joe321123

Technical User
Aug 31, 2012
3
US
Hey guys I'm a REXX newbie. I am writing a script using REXX in which I use larger numbers. I want to so some simple math routines like add and subtract. Could someone please explain why the following code doesn't work as expected...

say 2079476919 - 2079476916

Output:
0

Or perhaps why I get this

say 2079476919 + 1

Output:
2.07947692E+9

Or can someone tell me why the following is false.

IF 2079476916 >= 2079476919 THEN SAY "False"

Output:
False

BUT if I work with smaller number it works fine.

IF 6916 >= 6919 THEN DO
SAY "False"
END
ELSE DO
SAY "True"
END

Output:
True
 
Sorry I wish I could edit my post, I meant the following.


Or can someone tell me why the following is false.
Code:
IF 2079476916 >= 2079476919 THEN SAY "TRUE"

Output:
TRUE

BUT if I work with smaller number it works fine.

Code:
IF 6916 >= 6919 THEN DO
   SAY "TRUE"
END
ELSE DO
   SAY "FALSE"
END

Output:
FALSE
 
IIRC, the default numbwer of significant digits os 9.

If you want to use more, look at increasing the number of significant digits with
NUMERIC DIGITS.

Your experiment reverted to floating point to handle the number, i believe.
 
Yes! That certainly did the trick for me. Thanks! [bigsmile]

Code:
NUMERIC DIGITS 10

SAY 2079476916 + 1

Output:
2079476917
 
Good to hear it worked - thanks for letting us know<s>.

Sorrt 'bout the typos . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top