On Mon, 13 Sep 2021 23:34:41 -0400, Arthur T. <
[email protected]d>
declaimed the following:
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
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.
numeric digits 20
If the other responder is correct, Regina (and REXX implementations in general) may ignore this for loop boundaries. So the above documented convergence may come into play. There is also the consideration of whether
an implementation is using native integer arithmetic for loop indices
(would be fastest, and justify restriction to 32-bit integers).
-=-=-=-
/* REXX */
say "What!"
say 'digits() =' digits()
n = 2**31 /* a 10-digit number */
say "n" n
say "n+1" n+1
do i = 1 for n
say "In first loop for" n
leave i
end
numeric digits 20
say
say 'digits() =' digits()
n = 2**31 - 1
say "n" n
/*say "n+1" n+1*/
do i = 1 for n
say "In second loop for" n
leave i
end
say
n = 2**31
say "n" n
say "No increment for termination needed with a TO"
do i = 1 to n
say "In third loop TO" n
leave i
end
say
say "n" n
/* say "n+1" n+1 */
do i = 1 for n
say "In fourth loop for" n
leave i
end
-=-=-=-
Hmmm... Now this is interesting... Before adding the additional "say 'n+1'..." lines, I achieved
C:\Users\Wulfraed>regina t.rx
What!
digits() = 9
n 2.14748364E+9
In first loop for 2.14748364E+9
digits() = 20
n 2147483647
In second loop for 2147483647
n 2147483648
In third loop TO 2147483648
n 2147483648
32 +++ do i = 1 for n
Error 26 running "C:\Users\Wulfraed\t.rx", line 32: Invalid whole number
Error 26.3: Value of FOR expression in DO instruction must be zero or a positive whole number; found "2147483648"
But after the additions that changed to...
C:\Users\Wulfraed>regina t.rx
What!
digits() = 9
n 2.14748364E+9
n+1 2.14748364E+9
In first loop for 2.14748364E+9
digits() = 20
n 2147483647
n+1 2147483648
In second loop for 2147483647
n 2147483648
No increment for termination needed with a TO
In third loop TO 2147483648
n 2147483648
n+1 2147483649 <***********************************
36 +++ do i = 1 for n
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?
--
Wulfraed Dennis Lee Bieber AF6VN
[email protected] http://wlfraed.microdiversity.freeddns.org/
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)