Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FORMAT function is non-standard #43

Open
mgrossmann opened this issue Sep 17, 2019 · 3 comments
Open

FORMAT function is non-standard #43

mgrossmann opened this issue Sep 17, 2019 · 3 comments
Assignees
Labels
analysis Must be analyzed.

Comments

@mgrossmann
Copy link

The BRexx/370 FORMAT function, by definition under the Math functions documentation, is not the standard version of the Rexx FORMAT Built-in-Function as demonstrated in the BRexx documentation on FORMAT():

FORMAT(number[,[before][,[after][,[expp][,expt]]]])
rounds and formats number with before integer digits and after decimal places. expp accepts the values 1 or 2 (WARNING Totally differen't from the Ansi-REXX spec) where 1 means to use the "G" (General) format of C, and 2 the "E" exponential format of C. Where the place of the totalwidth specifier in C is replaced by before+after+1. ( expt is ignored! )

format(2.66) /* 3 */ 
format(2.66,1,1) /* 2.7 */ 
format(26.6,1,1,1) /* 3.E+01 */ 
format(26.6,1,1,2) /* 2.7E+01 */

I recommend for Rexx platform portability’s sake, that eventually, we do like what was done with the STORAGE() BiF, re-establishing the current FORMAT() BiF as BFORMAT and implementing the FORMAT() BiF as a Rexx standard FORMAT() BiF. I believe that I ran across a RexxFormat() external function somewhere that looked like it might fit the bill and provide the standard Rexx FORMAT() BiF functionality.
Oh yes, I did find it in the BRexx distribution, a RxLib external function called RexxFormat(). However, it is not fully flushed out and is not operational at this time. It’s probably 70% complete and eventually could become the standard (although external) version of the FORMAT() function for BRexx/370 with not too significant of an effort ...

@adesutherland
Copy link

Hello from https://github.com/adesutherland/CMS-370-BREXX !

Format is one of the built in functions which fails most terribly in our test suite - and I am thinking of porting Regina's implementation to BREXX (which may mean making a new maths implementation too ... troublesome but probably also a good thing).

Is this a sub-project that we can jointly look at?

@mgrossmann
Copy link
Author

Hello Adrian,

we can definitely imagine working together. It doesn't make much sense to develop everything two or three times.

Mike

@rvjansen
Copy link

rvjansen commented Mar 26, 2024

With a test case supplied by Walter Pachl, the difference between BREXX on MVS and CMS can be shown:

 /* */                                      
 PARSE VERSION V                            
 SAY V                                      
 _="    -0.05625000000000000000"            
 SAY '_='_                                  
 SAY 'FORMAT(_/1, 6)' FORMAT(_/1, 6)        
 SAY 'FORMAT(_+0, 6)' FORMAT(_+0, 6)        
 SAY 'FORMAT(_  , 6)' FORMAT(_  , 6)        
 _="     0.05625000000000000000"            
 SAY 'FORMAT(_/1, 6)' FORMAT(_/1, 6)        
 SAY 'FORMAT(_+0, 6)' FORMAT(_+0, 6)        
 SAY 'FORMAT(_  , 6)' FORMAT(_  , 6)        

output on MVSTK5:

BREXX/370 V2R5M2 (Mar 02 2023) 
 _=    -0.05625000000000000000  
 FORMAT(_/1, 6)   -0.0          
 FORMAT(_+0, 6)   -0.0          
 FORMAT(_  , 6)   -0.0          
 FORMAT(_/1, 6)    0.0          
 FORMAT(_+0, 6)    0.0          
 FORMAT(_  , 6)    0.0       

output on VM/370CE:

CMS bREXX 1.0.1 Jul  5 2022  
_=    -0.05625000000000000000
FORMAT(_/1, 6)     -0.05625  
FORMAT(_+0, 6)     -0.05625  
FORMAT(_  , 6)     -0.05625  
FORMAT(_/1, 6)      0.05625  
FORMAT(_+0, 6)      0.05625  
FORMAT(_  , 6)      0.05625  

expected output:

REXX370 4.02 01 Dec 1998               
_=    -0.05625000000000000000          
format(_/1, 6)     -0.05625            
format(_+0, 6)     -0.0562500000       
format(_  , 6)     -0.0562500000       
format(_/1, 6)      0.05625            
format(_+0, 6)      0.0562500000       
format(_  , 6)      0.0562500000       

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analysis Must be analyzed.
Projects
None yet
Development

No branches or pull requests

4 participants