• Re: Negative number division

    From minforth@21:1/5 to All on Sat Jun 1 18:40:09 2024
    There is a totally unknown esoteric language called Python:

    MicroPython v1.19.1 on 2022-11-05; win32 [GCC 6.3.0] version
    Use Ctrl-D to exit, Ctrl-E for paste mode
    a = -3
    b = 10
    print( a // b )
    -1

    How dare they!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to LIT on Sat Jun 1 22:17:45 2024
    In article <934f71364665670db96601dc5652c232@www.novabbs.com>,
    LIT <zbigniew2011@gmail.com> wrote:
    These Pythoneers are indeed impudent.
    Fortumately the creators of (most of) DOS Forths
    and CPU designers themselves shared my opinion.

    Actually I agree with gForth and Python that a / that is compatible
    with FM/MOD is preferable. Changing it in ciforth is a major change,
    so that it has to go with a change of the primary version number
    (now 5.5.1) It has to wait for version 6.#.# .

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat purring. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ron AARON@21:1/5 to LIT on Sun Jun 2 08:35:33 2024
    8th: -3 10 / .
    -0.30000

    On 01/06/2024 21:19, LIT wrote:
    Only a few examples from within Linux console:

    Gforth: -3 10 / . -1  ok
    PForth: -3 10 / . 0    ok
    ciforth: S[ ] OK -3 10 / .
    0 ESP32Forth: --> -3 10 / . -1  ok

    TCL: % expr -3 / 10
    -1

    ANSI-C: printf("%d\n", -3 / 10) gives output 0

    Guys, whatever you can write about floored/non-floored
    division -- it's nothing more than kind of "dialectic".
    When one divides -3 by 10 the result CANNOT be higher/lower
    than 0, because there's larger difference between -10 and -3
    than between 0 and -3. Simple.
    The -1 result is contrary to logic. It's nonsense.

    From what I see even TCL is sick for this "floorness",
    not just quite a few Forths.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to albert@spenarnc.xs4all.nl on Sun Jun 2 06:37:44 2024
    albert@spenarnc.xs4all.nl wrote:

    Actually I agree with gForth and Python that a / that is compatible
    with FM/MOD is preferable. Changing it in ciforth is a major change,
    so that it has to go with a change of the primary version number
    (now 5.5.1) It has to wait for version 6.#.# .

    In over 40 years of using Forth, I remember only a single instance
    where I had a problem in a non-benchmark situation.

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to LIT on Sun Jun 2 11:23:26 2024
    zbigniew2011@gmail.com (LIT) writes:
    Guys, whatever you can write about floored/non-floored
    division -- it's nothing more than kind of "dialectic".
    When one divides -3 by 10 the result CANNOT be higher/lower
    than 0, because there's larger difference between -10 and -3
    than between 0 and -3. Simple.
    The -1 result is contrary to logic. It's nonsense.

    If you prefer symmetric division, standard Forth provides SM/REM. In
    addition, the development version of Gforth provides a complete set of symmetric (and floored) words complementing the standard (implementation-defined ones):

    Symmetric: /s mods /mods */mods */s

    Floored: /f modf /modf */modf */f

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2023: https://euro.theforth.net/2023

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ahmed@21:1/5 to All on Sun Jun 2 12:16:21 2024
    Hi,

    Gforth 0.7.9_20200709
    Authors: Anton Ertl, Bernd Paysan, Jens Wilke et al., for more type
    `authors'
    Copyright © 2019 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later
    <https://gnu.org/licenses/gpl.html>
    Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
    Type `help' for basic help
    ok
    ok
    ok
    -3 10 / . -1 ok
    -3 10 /s . 0 ok
    -3 10 /f . -1 ok

    It works.

    Ahmed

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to LIT on Sun Jun 2 16:00:46 2024
    zbigniew2011@gmail.com (LIT) writes:
    If you prefer symmetric division, standard Forth provides SM/REM. In
    addition, the development version of Gforth provides a complete set of
    symmetric (and floored) words complementing the standard
    (implementation-defined ones):

    Symmetric: /s mods /mods */mods */s

    Floored: /f modf /modf */modf */f

    1. Which version? 0.7.3 -- described as
    "Latest release" doesn't know that:

    Yes. It's in the development version since February 2020.

    2. I guess (looking at these words) that there's
    a "switch" implemented, that "vectorizes" usual
    / mod etc. using these two sets?

    If you mean that / is a deferred word or somesuch that can be directed
    to perform /f or /s (and likewise for MOD /MOD */MOD */), no, that's
    not the case, because that is a bad idea. It would change the
    behaviour of existing words. E.g., if a piece of code checks whether
    / is floored and then uses it in a definition in a way that is correct
    for floored division, that definition would become wrong if / is
    redirected to be symmetric. E.g.:

    -1 3 / -1 [if]
    : /s
    2dup /
    ... \ add 1 in some cases
    ;
    [else]
    synonym /s /
    [then]

    Therefore, Gforth statically defines, e.g.

    ' /f alias /

    If you want a symmetric /, you can define

    ' /s alias /

    However, if your program relies on symmetric behaviour, it's better to
    call /S, and to define that on systems that do not have it; on systems
    with symmetric /, the definition would be as simple as

    synonym /s /

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2023: https://euro.theforth.net/2023

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to mhx on Sun Jun 2 21:49:37 2024
    In article <7d54fed039a725e589d1ddeb2fec4c78@www.novabbs.com>,
    mhx <mhx@iae.nl> wrote:
    albert@spenarnc.xs4all.nl wrote:

    Actually I agree with gForth and Python that a / that is compatible
    with FM/MOD is preferable. Changing it in ciforth is a major change,
    so that it has to go with a change of the primary version number
    (now 5.5.1) It has to wait for version 6.#.# .

    In over 40 years of using Forth, I remember only a single instance
    where I had a problem in a non-benchmark situation.

    Actually there is only a problem if you are not aware of different
    possibities how / and MOD is defined.
    If you are used to one system and you use it consistently you
    hardly notice.


    -marcel

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat purring. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dave_thompson_2@comcast.net@21:1/5 to LIT on Sun Aug 25 17:10:43 2024
    Sorry for delay, I misplaced this and just re-found it.

    On Sat, 1 Jun 2024 18:19:32 +0000, zbigniew2011@gmail.com (LIT) wrote:
    ...
    ANSI-C: printf("%d\n", -3 / 10) gives output 0

    "ANSI C" is ambiguous. When the first C standard was created in 1989
    by ASC X3 J11 people called it ANSI. That standard was then adopted
    with only editorial changes by "ISO" (technically, ISO/IEC JTC1 SC22).
    Since then several revised standards have been _jointly_ developed by
    the ANSI subcommittee (now mutated into INCITS) and the ISO one, and
    published by ANSI, ISO, and other national members.

    Some people reserve the name "ANSI C" only for C89/90, while some
    apply it to the newer versions in which ANSI participates but no
    longer controls. This matters here because C89/90 made rounding of
    division with a negative operand implementation-dependent (and
    required % for remainder to be consistent with division always so with
    a negative operand it was also implementation-dependent). C99 and
    later -- which per above might or might not be called "ANSI C" --
    standardized division rounding as toward-zero (and % consistent).

    Current C implementations follow the newer standards, unless you
    resurrect an ancient one, like Borland Turbo C on an emulated (i.e.
    fake) PC/AT with MSDOS 2 or something like that.

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