IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Difference in Reginald and Mainframe results for REXX script


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ashutosh.pr

New User


Joined: 13 Apr 2007
Posts: 36
Location: Pune

PostPosted: Fri Sep 18, 2009 12:28 pm
Reply with quote

Hi,
I just encountered this while starting to learn REXX.

I run the same script on the mainframes after putting it in a PDS member and separately in a notepad using Regina interpreter.

The script is:
/* REXX */
A = '125' ; B = '125' ;
NUMERIC FORM SCIENTIFIC
prod = A ** B;
SAY prod;


I get the following results:

Mainframes:
1.29942622E+262

Regina:
1.29942623E+262

Anyone aware of this issue and the probable reason for this?

Thanks,
Ashutosh
Back to top
View user's profile Send private message
mtaylor

Active User


Joined: 20 Feb 2009
Posts: 108
Location: Kansas City

PostPosted: Fri Sep 18, 2009 5:41 pm
Reply with quote

Clearly you're assuming floating point arithmetic is standard across machines and it isn't. So, the same operation does not give the same answer on two different machines and you have no right to expect it to. Adoption of floating point standards has been a contentious issue over the years. Nowadays, IEEE 754 is becoming the defacto 'standard' and it's welcome.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Sep 18, 2009 6:01 pm
Reply with quote

Mainframe is right, Regina is very wrong.

Code:
Expression: 125**125                                               
Result    : 1.299426220705612402316300572585238295973692851047E+262
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Sep 18, 2009 7:32 pm
Reply with quote

Have you ever studied precision and accuracy of numerical computations in any course? If so, you should not be surprised by these results.

A simple test is to set up a COMP-2 field in a COBOL program, set it to 1 and multiply it by each integer from 2 to 30. Repeat the test starting at 30 and going down to 1. You will find the displayed results are not the same even though mathematically the exact same computations are being done.

Mathematics implies, at times, infinite number of digits for numbers. Computers do not handle infinite numbers of digits, so the results returned by a given set of mathematical operations (1) may be affected by the order in which computations are done, and (2) may or may not resemble the mathematical result. This applies even more when dealing with different platforms or even different compilers / interpreters on a single platform.
Back to top
View user's profile Send private message
ashutosh.pr

New User


Joined: 13 Apr 2007
Posts: 36
Location: Pune

PostPosted: Sat Sep 19, 2009 8:00 am
Reply with quote

Thank you all!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Mainframe openings in Techmahnidra fo... Mainframe Jobs 0
Search our Forums:

Back to Top