mvslovers / brexx370

MVS version of Vasilis Vlachoudis awesome rexx implementation
44 stars 11 forks source link

FORMAT function is non-standard #43

Open mgrossmann opened 4 years ago

mgrossmann commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Hello Adrian,

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

Mike

rvjansen commented 4 months ago

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