Open rvjansen opened 3 months ago
Mark Hessling ran the test with CRX, which is the ANSI compatibility checker implementation by Brian Marks. This resulted in the following output:
REXX 5.00 22 April 99
_= -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
which, I think, shows that NetRexx has a few zeroes too much on the end of the format(_ , 6)
call.
There is more to it than meets the eye.. Consider the following rexx program
/* REXX */
Parse Version v
Say v
_=" -0.05625000000000000000"
Say '_='_
numdigits = 4
numeric digits numdigits
say 'numeric digits 'numdigits''
Say 'format(_/1, 6)' format(_/1, 6) 'format(_/1)' format(_/1) '(' _/1 ')'
Say 'format(_+0, 6)' format(_+0, 6) 'format(_+0)' format(_+0) '(' _+0 ')'
Say 'format(_ , 6)' format(_ , 6) 'format(_ )' format(_) '(' _ ')'
numdigits = 5
numeric digits numdigits
say 'numeric digits 'numdigits''
Say 'format(_/1, 6)' format(_/1, 6) 'format(_/1)' format(_/1) '(' _/1 ')'
Say 'format(_+0, 6)' format(_+0, 6) 'format(_+0)' format(_+0) '(' _+0 ')'
Say 'format(_ , 6)' format(_ , 6) 'format(_ )' format(_) '(' _ ')'
numdigits = 9
numeric digits numdigits
say 'numeric digits 'numdigits''
Say 'format(_/1, 6)' format(_/1, 6) 'format(_/1)' format(_/1) '(' _/1 ')'
Say 'format(_+0, 6)' format(_+0, 6) 'format(_+0)' format(_+0) '(' _+0 ')'
Say 'format(_ , 6)' format(_ , 6) 'format(_ )' format(_) '(' _ ')'
with output
remesm@xps:testcases$ nr format.nrx
NetRexx 4.07 11 Mar 2024
_= -0.05625000000000000000
numeric digits 4
format(_/1, 6) -0.05625 format(_/1) -0.05625 ( -0.05625 )
format(_+0, 6) -0.05625 format(_+0) -0.05625 ( -0.05625 )
format(_ , 6) -0.05625000000000000000 format(_ ) -0.05625000000000000000 ( -0.05625000000000000000 )
numeric digits 5
format(_/1, 6) -0.05625 format(_/1) -0.05625 ( -0.05625 )
format(_+0, 6) -0.056250 format(_+0) -0.056250 ( -0.056250 )
format(_ , 6) -0.05625000000000000000 format(_ ) -0.05625000000000000000 ( -0.05625000000000000000 )
numeric digits 9
format(_/1, 6) -0.05625 format(_/1) -0.05625 ( -0.05625 )
format(_+0, 6) -0.0562500000 format(_+0) -0.0562500000 ( -0.0562500000 )
format(_ , 6) -0.05625000000000000000 format(_ ) -0.05625000000000000000 ( -0.05625000000000000000 )
remesm@xps:testcases$ rexx format.nrx
REXX-ooRexx_5.1.0(MT)_64-bit 6.05 12 Feb 2024
_= -0.05625000000000000000
numeric digits 4
format(_/1, 6) -0.056250 format(_/1) -0.056250 ( -0.05625 )
format(_+0, 6) -0.056250 format(_+0) -0.056250 ( -0.05625 )
format(_ , 6) -0.056250 format(_ ) -0.056250 ( -0.05625000000000000000 )
numeric digits 5
format(_/1, 6) -0.056250 format(_/1) -0.056250 ( -0.05625 )
format(_+0, 6) -0.0562500 format(_+0) -0.0562500 ( -0.056250 )
format(_ , 6) -0.0562500 format(_ ) -0.0562500 ( -0.05625000000000000000 )
numeric digits 9
format(_/1, 6) -0.056250 format(_/1) -0.056250 ( -0.05625 )
format(_+0, 6) -0.05625000000 format(_+0) -0.05625000000 ( -0.0562500000 )
format(_ , 6) -0.05625000000 format(_ ) -0.05625000000 ( -0.05625000000000000000 )
remesm@xps:testcases$ regina-rexx-3.9.5/rexx format.nrx
REXX-Regina_3.9.5 5.00 25 Jun 2022
_= -0.05625000000000000000
numeric digits 4
format(_/1, 6) -0.05625 format(_/1) -0.05625 ( -0.05625 )
format(_+0, 6) -0.05625 format(_+0) -0.05625 ( -0.05625 )
format(_ , 6) -0.05625 format(_ ) -0.05625 ( -0.05625000000000000000 )
numeric digits 5
format(_/1, 6) -0.05625 format(_/1) -0.05625 ( -0.05625 )
format(_+0, 6) -0.05625 format(_+0) -0.056250 ( -0.056250 )
format(_ , 6) -0.05625 format(_ ) -0.056250 ( -0.05625000000000000000 )
numeric digits 9
format(_/1, 6) -0.05625 format(_/1) -0.05625 ( -0.05625 )
format(_+0, 6) -0.05625 format(_+0) -0.0562500000 ( -0.0562500000 )
format(_ , 6) -0.05625 format(_ ) -0.0562500000 ( -0.05625000000000000000 )
oorexx (5.1 and 5.0), regina rexx and NetRexx all provide inconsistent output for the same program. Both oorexx and regina rexx do not specify the output when the after argument (or no argument) is not provided, so arguably their output is correct. NetRexx specifies when after is not provided, 'the number of characters used will be as many as are needed for that part.' If no arguments are given, 'the number is formatted by adding zero with a digits setting that is either nine or, if greater, the number of digits in the mantissa of the number. So, arguably, NetRexx is more precise in its output.
I don't see why oorexx adds a zero to both format(/1, 6) and format(+1, 6)
It seems, all is related to the internal representation of numbers in correlation with NUMERIC DIGITS instruction, in which all are consistent.
But while playing with the NUMERIC DIGITS instruction, I stumbled this strange operation of the instruction. Apparently all zero's are discarded as insignificant until the first non-zero number, from where the DIGITS start counting.
Given
/* REXX */
Parse Version v
Say v
numdigits = 4
numeric digits numdigits
_=" -0.01234567890000"
Say '_='_
Say 'format(_/1, 6)' format(_/1, 6)
Say 'format(_+0, 6)' format(_+0, 6)
Say 'format(_ , 6)' format(_ , 6)
_=" -0.12345678900000"
Say '_='_
Say 'format(_/1, 6)' format(_/1, 6)
Say 'format(_+0, 6)' format(_+0, 6)
Say 'format(_ , 6)' format(_ , 6)
remesm@xps:testcases$ nr numeric.nrx
NetRexx 4.07 11 Mar 2024
_= -0.01234567890000
format(_/1, 6) -0.01235
format(_+0, 6) -0.01235
format(_ , 6) -0.01234567890000
_= -0.12345678900000
format(_/1, 6) -0.1235
format(_+0, 6) -0.1235
format(_ , 6) -0.12345678900000
remesm@xps:testcases$ rexx numeric.nrx
REXX-ooRexx_5.1.0(MT)_64-bit 6.05 12 Feb 2024
_= -0.01234567890000
format(_/1, 6) -0.012350
format(_+0, 6) -0.012355
format(_ , 6) -0.012355
_= -0.12345678900000
format(_/1, 6) -0.1235
format(_+0, 6) -0.1235
format(_ , 6) -0.1235
remesm@xps:testcases$ regina-rexx-3.9.5/rexx numeric.nrx
REXX-Regina_3.9.5 5.00 25 Jun 2022
_= -0.01234567890000
format(_/1, 6) -0.01235
format(_+0, 6) -0.01235
format(_ , 6) -0.0123456789
_= -0.12345678900000
format(_/1, 6) -0.1235
format(_+0, 6) -0.1235
format(_ , 6) -0.123456789
Again oorexx adds a zero, additionally it does not honor numeric digits 4.
But all start counting 'significant' digits after the first non-zero number. Should it not start counting digits after the dot? In other words, with NUMERIC DIGITS 4, should the output not be as below?
_= -0.01234567890000
format(_/1, 6) -0.0123
format(_+0, 6) -0.0123
_= -0.12345678900000
format(_/1, 6) -0.1235
format(_+0, 6) -0.1235
Marc
with the following testcase (from Walter Pachl):
results in
when expected result is:
Note that this result is obtained with JVM8 or JVM>=9 with -exec (interpreted).
_
is not supported with Java =>9, will be a separate issue, but irrelevant to this issue.