• Possible bug in Regina with FOR repetitor 2**31 or greater

    From Arthur T.@21:1/5 to All on Mon Sep 13 23:34:41 2021
    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>

    --
    Arthur T. - ar23hur "at" pobox "dot" com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anonymous@21:1/5 to All on Tue Sep 14 11:59:39 2021
    I plan to open a report of this problem, but I'm having difficulty
    deciding on a pithy, meaningful title. Have you any suggestions?

    27 +++ do i = 1 for n
    line 27: Invalid whole number
    Error 26.3: Value of FOR expression in DO instruction must be zero or a positive whole number; found "2147483648"

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rony@21:1/5 to Arthur T. on Tue Sep 14 17:48:16 2021
    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>


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rick McGuire@21:1/5 to Rony on Wed Sep 15 05:36:51 2021
    On Tuesday, September 14, 2021 at 11:48:18 AM UTC-4, Rony wrote:
    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>

    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 examples
    explicitly listed.

    Rick

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dennis Lee Bieber@21:1/5 to All on Wed Sep 15 14:26:17 2021
    On Mon, 13 Sep 2021 23:34:41 -0400, Arthur T. <arthur@munged.invalid>
    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
    wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Arthur T.@21:1/5 to Rick McGuire on Wed Sep 15 15:59:31 2021
    In
    Message-ID:<56dc90ab-4168-46f8-ba46-240ff749ddb8n@googlegroups.com>,
    Rick McGuire <object.rexx@gmail.com> wrote:

    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 examples
    explicitly listed.

    Thank you!

    I'm glad I asked here before opening a problem. And, yes, TRL2 says
    that exprf (FOR operand) can be limited, but doesn't put exprt (TO
    operand) in the same category. And that exactly matches the results
    of my test code.

    WAD even if some of us didn't realize it. I hate to think that I may
    have to actually read (or at least skim through) TRL2, but this shows
    why I should (have).

    --
    Arthur T. - ar23hur "at" pobox "dot" com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Arthur T.@21:1/5 to Dennis Lee Bieber on Wed Sep 15 23:37:48 2021
    In Message-ID:<mnb4kgpjm6gn62lmhpabi2pqj9mqajkvmd@4ax.com>,
    Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:

    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.

    That convergence is probably (somehow) why this didn't cause an error
    with the default 9-digits of accuracy. And Rick McGuire explained
    why, with 20 digits it works with TO but not with FOR.

    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"



    --
    Arthur T. - ar23hur "at" pobox "dot" com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dennis Lee Bieber@21:1/5 to All on Thu Sep 16 11:51:16 2021
    On Wed, 15 Sep 2021 23:37:48 -0400, Arthur T. <arthur@munged.invalid>
    declaimed the following:

    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"

    While I cited the 3.9.1 manual, I'm pretty certain I was running 3.9.3...

    C:\Users\Wulfraed>rexx
    parse version ver
    say ver
    ^Z
    REXX-Regina_3.9.3 5.00 5 Oct 2019

    C:\Users\Wulfraed>

    Hmmm, your expanded result looks like a garbage attempt at a 10^9 tail



    --
    Wulfraed Dennis Lee Bieber AF6VN
    wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Glenn Knickerbocker@21:1/5 to Rick McGuire on Sat Jan 29 12:56:52 2022
    On Wed, 15 Sep 2021 05:36:51 -0700 (PDT), Rick McGuire wrote:
    Error 26.3: Value of FOR expression in DO instruction must be zero
    or a positive whole number; found "2147483648"
    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 examples explicitly listed.

    This seems weird when a smaller value of DIGITS() causes smaller numbers
    to be rejected, but I see it says that an implementation restriction
    *may* apply, and that 9 is the *mininum* length that must be supported.
    So Regina is actually supporting a little *more* than required here.
    Trying it in ooRexx, I get this error starting right at 1E10.

    ČR

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)