I plan to open a report of this problem, but I'm having difficulty
deciding on a pithy, meaningful title. Have you any suggestions?
I plan to open a report of this problem, but I'm having difficulty
deciding on a pithy, meaningful title. Have you any suggestions?
Feel free to point out how I've misinterpreted something and that
this isn't an actual bug. That's happened to me before. I couldn't
find anything in the documentation suggesting this limit. Does it
fail for other people? Does it fail or work on other REXXes?
If you try it, you may see that the error message on 3.9.3 is even
weirder than on older versions. Regardless of level, notice the
difference between DO I = 1 FOR N and DO I = 1 TO N.
<code>
say 'digits() =' digits()
n = 2**31 /* a 10-digit number */
say format(n,,,0) length(n) '(' || n || ')'
do i = 1 for n
say "In first loop for" n
leave i
end
numeric digits 20
say 'digits() =' digits()
n = 2**31 - 1
say format(n,,,0) length(n) '(' || n || ')'
do i = 1 for n
say "In second loop for" n
leave i
end
n = 2**31
say format(n,,,0) length(n) '(' || n || ')'
do i = 1 to n
say "In third loop TO" n
leave i
end
/*
The following yields:
Error 26.3: Value of FOR expression in DO instruction must be zero
or a positive whole number; found "2147483648"
*/
do i = 1 for n
say "In fourth loop for" n
leave i
end
exit 0
</code>
By default Rexx uses nine digits for a number. A whole number therefore cannot be larger than
999999999, which 2**31 is, hence the error.
Here a rexxtry.rex session (using ooRexx but this would not matter for this case):
F:\work\svn\bsf4oorexx\trunk\bsf4oorexx.dev\source_java>rexxtry REXX-ooRexx_5.0.0(MT)_32-bit 6.05 13 Aug 2021
rexxtry.rex lets you interactively try REXX statements.
Each string is executed when you hit Enter.
Enter 'call tell' for a description of the features.
Go on - try a few... Enter 'exit' to end.
say digits()
9
........................................... rexxtry.rex on WindowsNT
say 2**32
4.2949673E+9
........................................... rexxtry.rex on WindowsNT
say 2**31
2.14748365E+9
........................................... rexxtry.rex on WindowsNT
numeric digits 10
........................................... rexxtry.rex on WindowsNT
say 2**31
2147483648
........................................... rexxtry.rex on WindowsNT
say 2**32
4294967296
........................................... rexxtry.rex on WindowsNT
As you see, once you use ten digits for a number, 2**31 and 2**32 qualify again as whole numbers.
HTH,
---rony
On 14.09.2021 05:34, Arthur T. wrote:
I plan to open a report of this problem, but I'm having difficulty deciding on a pithy, meaningful title. Have you any suggestions?
Feel free to point out how I've misinterpreted something and that
this isn't an actual bug. That's happened to me before. I couldn't
find anything in the documentation suggesting this limit. Does it
fail for other people? Does it fail or work on other REXXes?
If you try it, you may see that the error message on 3.9.3 is even
weirder than on older versions. Regardless of level, notice the
difference between DO I = 1 FOR N and DO I = 1 TO N.
<code>
say 'digits() =' digits()
n = 2**31 /* a 10-digit number */
say format(n,,,0) length(n) '(' || n || ')'
do i = 1 for n
say "In first loop for" n
leave i
end
numeric digits 20
say 'digits() =' digits()
n = 2**31 - 1
say format(n,,,0) length(n) '(' || n || ')'
do i = 1 for n
say "In second loop for" n
leave i
end
n = 2**31
say format(n,,,0) length(n) '(' || n || ')'
do i = 1 to n
say "In third loop TO" n
leave i
end
/*
The following yields:
Error 26.3: Value of FOR expression in DO instruction must be zero
or a positive whole number; found "2147483648"
*/
do i = 1 for n
say "In fourth loop for" n
leave i
end
exit 0
</code>
Feel free to point out how I've misinterpreted something and that
this isn't an actual bug. That's happened to me before. I couldn't
find anything in the documentation suggesting this limit. Does it
fail for other people? Does it fail or work on other REXXes?
If you try it, you may see that the error message on 3.9.3 is even
weirder than on older versions. Regardless of level, notice the
difference between DO I = 1 FOR N and DO I = 1 TO N.
<code>
say 'digits() =' digits()
n = 2**31 /* a 10-digit number */
say format(n,,,0) length(n) '(' || n || ')'
do i = 1 for n
say "In first loop for" n
leave i
end
numeric digits 20
Even with a higher digits setting, this value is rejected for the FOR argument. This falls into the category of "numbers used directly by REXX" described on page 137 of The REXX Language, second edition. The exprf expression is one of the examplesexplicitly listed.
On Mon, 13 Sep 2021 23:34:41 -0400, Arthur T. <arthur@munged.invalid> >declaimed the following:
<code>
say 'digits() =' digits()
n = 2**31 /* a 10-digit number */
say format(n,,,0) length(n) '(' || n || ')'
do i = 1 for n
say "In first loop for" n
leave i
end
Regina reference manual (3.9.1 manual, haven't seen a newer one) page
37 "Loop Convergence" might have a part to play. Not sure. You might have
to let the loop run to completion to find out. Might also depend upon how >Regina really implements "for n" termination. I'd probably write the >interpreter to convert to a "to n+start" internally -- and if the statement >already included a "to m" clause, keep the lowest termination.
Error 26 running "C:\Users\Wulfraed\t.rx", line 36: Invalid whole number >Error 26.3: Value of FOR expression in DO instruction must be zero or a >positive whole number; found "21474836484799" <*************
WHICH definitely looks like an error somewhere in the conversion! (I
removed those statements, and the output went back to 2147483648)... Either >"n + 1" with digits 20 causes the error, the one with digits 9 does not. A >problem in the extended math modes?
It's even weirder in Regina 3.9.3 because the error message from my
original example is:
Error 26.3: Value of FOR expression in DO instruction must be zero or
a positive whole number; found "2147483648 109"
Even with a higher digits setting, this value is rejected for the FOR >argument. This falls into the category of "numbers used directly byError 26.3: Value of FOR expression in DO instruction must be zero
or a positive whole number; found "2147483648"
REXX" described on page 137 of The REXX Language, second edition. The
exprf expression is one of the examples explicitly listed.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 24:09:49 |
Calls: | 6,646 |
Calls today: | 1 |
Files: | 12,193 |
Messages: | 5,327,713 |