Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"What the scientists have in their briefcases is terrifying." -- Nikita Khrushchev


devel / comp.arch / Re: floored vs. symmetric integer division

SubjectAuthor
* Re: MMU MusingsTim Rentsch
`* floored vs. symmetric integer divisionAnton Ertl
 +* Re: floored vs. symmetric integer divisionMichael S
 |+* Re: floored vs. symmetric integer divisionAnton Ertl
 ||+* Re: floored vs. symmetric integer divisionMichael S
 |||+* Re: floored vs. symmetric integer divisionAnton Ertl
 ||||`* Re: floored vs. symmetric integer divisionMichael S
 |||| `- Re: floored vs. symmetric integer divisionAnton Ertl
 |||`* Re: floored vs. symmetric integer divisionMichael S
 ||| `* Re: floored vs. symmetric integer divisionMichael S
 |||  `- Re: floored vs. symmetric integer divisionThomas Koenig
 ||`- Re: floored vs. symmetric integer divisionTim Rentsch
 |`* Re: floored vs. symmetric integer divisionJohn Levine
 | `* Re: floored vs. symmetric integer divisionAnton Ertl
 |  `- Re: floored vs. symmetric integer divisionJohn Levine
 `- Re: floored vs. symmetric integer divisionTim Rentsch

1
Re: MMU Musings

<86mszqxo3n.fsf@linuxsc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33320&group=comp.arch#33320

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17687@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: MMU Musings
Date: Thu, 20 Jul 2023 14:35:56 -0700
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <86mszqxo3n.fsf@linuxsc.com>
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <2023Mar13.185740@mips.complang.tuwien.ac.at> <gx6QL.71863$Kqu2.56574@fx01.iad> <be0234cc-6ce9-4534-b601-e43ae2d4aaeen@googlegroups.com> <bOlQL.1586560$9sn9.355216@fx17.iad> <b233aab2-c5ff-465b-aace-a89aefcaab3dn@googlegroups.com> <27e5453d-c69f-4f1d-9e4f-73c6ebf5829en@googlegroups.com> <lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me> <2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me> <2023Mar22.185044@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="3857442d865f8a7bff3454fde02b814b";
logging-data="3037961"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19t7BBbxEdjbB5GHV0wi9vtyAJmjHTKzcM="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:dh2itgxyfjEE7jDq35tJxIKCjYs=
sha1:BincG/GqvNtStBWi5cPqwDLBvp0=
 by: Tim Rentsch - Thu, 20 Jul 2023 21:35 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:

> Ivan Godard <ivan@millcomputing.com> writes:
>
>> On 3/20/2023 7:20 AM, Anton Ertl wrote:
>>
>>> Ivan Godard <ivan@millcomputing.com> writes:
>>>
>>>> (-1)/2 is not a shift except in ones-comp and sign-mag.
>>>
>>> Sure is:
>>>
>>> -1 2 / .
>>> -1 1 arshift .
>>>
>>> Running Gforth 0.7.9_20230317, both output "-1".
>>>
>>> Do you mean to tell me that the Mill has all kinds of options for
>>> dealing with overflow, but does not support floored or Euclidean (same
>>> results for positive divisors) division?
>>
>> Looks like you assume round toward -inf. Why?
>
> Because it has much nicer behaviour when the dividend crosses 0 than
> round-towards-0 has:
>
> round-towards-0 (aka truncated):
>
> https://en.wikipedia.org/wiki/File:Divmod_truncated.svg
>
> round towards -inf (floored):
>
> https://en.wikipedia.org/wiki/File:Divmod_floored.svg

Nicer behavior is in the eye of the beholder.

The graph for round towards -inf may look more pleasing to
the eye.

But round towards zero is mathematically nicer:

(-x)/y == - (x/y)

To me the mathematical picture is the more important one.

floored vs. symmetric integer division

<2023Jul21.073302@mips.complang.tuwien.ac.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33340&group=comp.arch#33340

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: floored vs. symmetric integer division
Date: Fri, 21 Jul 2023 05:33:02 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 38
Message-ID: <2023Jul21.073302@mips.complang.tuwien.ac.at>
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <be0234cc-6ce9-4534-b601-e43ae2d4aaeen@googlegroups.com> <bOlQL.1586560$9sn9.355216@fx17.iad> <b233aab2-c5ff-465b-aace-a89aefcaab3dn@googlegroups.com> <27e5453d-c69f-4f1d-9e4f-73c6ebf5829en@googlegroups.com> <lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me> <2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me> <2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com>
Injection-Info: dont-email.me; posting-host="b4083f02a715932b678d428de9f1a4c7";
logging-data="3295582"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XYLBeHuSoqPTZbMH29+NO"
Cancel-Lock: sha1:bRA8VX9aVbJT8W0e/dFOtZTFYjc=
X-newsreader: xrn 10.11
 by: Anton Ertl - Fri, 21 Jul 2023 05:33 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
[floored division]
>> Because it has much nicer behaviour when the dividend crosses 0 than
>> round-towards-0 has:
>>
>> round-towards-0 (aka truncated):
>>
>> https://en.wikipedia.org/wiki/File:Divmod_truncated.svg
>>
>> round towards -inf (floored):
>>
>> https://en.wikipedia.org/wiki/File:Divmod_floored.svg
>
>Nicer behavior is in the eye of the beholder.
>
>The graph for round towards -inf may look more pleasing to
>the eye.
>
>But round towards zero is mathematically nicer:
>
> (-x)/y == - (x/y)

But round towards -inf is mathematically nicer:

(x+y)/y = (x/y)+1

And in practice, that's more frequently useful.

>To me the mathematical picture is the more important one.

People who prefer floored or Euklidean division also give mathematical
arguments.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: floored vs. symmetric integer division

<e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33346&group=comp.arch#33346

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:8e3:b0:636:3fbd:84e with SMTP id dr3-20020a05621408e300b006363fbd084emr5470qvb.5.1689934074989;
Fri, 21 Jul 2023 03:07:54 -0700 (PDT)
X-Received: by 2002:a05:6870:93d5:b0:1ba:7bf5:67cd with SMTP id
c21-20020a05687093d500b001ba7bf567cdmr2309592oal.11.1689934074732; Fri, 21
Jul 2023 03:07:54 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 21 Jul 2023 03:07:54 -0700 (PDT)
In-Reply-To: <2023Jul21.073302@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:2df4:e81f:b2d4:e4df;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:2df4:e81f:b2d4:e4df
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com>
<be0234cc-6ce9-4534-b601-e43ae2d4aaeen@googlegroups.com> <bOlQL.1586560$9sn9.355216@fx17.iad>
<b233aab2-c5ff-465b-aace-a89aefcaab3dn@googlegroups.com> <27e5453d-c69f-4f1d-9e4f-73c6ebf5829en@googlegroups.com>
<lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me>
<2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me>
<2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com> <2023Jul21.073302@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com>
Subject: Re: floored vs. symmetric integer division
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Fri, 21 Jul 2023 10:07:54 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3414
 by: Michael S - Fri, 21 Jul 2023 10:07 UTC

On Friday, July 21, 2023 at 8:39:44 AM UTC+3, Anton Ertl wrote:
> Tim Rentsch <tr.1...@z991.linuxsc.com> writes:
> >an...@mips.complang.tuwien.ac.at (Anton Ertl) writes:
> [floored division]
> >> Because it has much nicer behaviour when the dividend crosses 0 than
> >> round-towards-0 has:
> >>
> >> round-towards-0 (aka truncated):
> >>
> >> https://en.wikipedia.org/wiki/File:Divmod_truncated.svg
> >>
> >> round towards -inf (floored):
> >>
> >> https://en.wikipedia.org/wiki/File:Divmod_floored.svg
> >
> >Nicer behavior is in the eye of the beholder.
> >
> >The graph for round towards -inf may look more pleasing to
> >the eye.
> >
> >But round towards zero is mathematically nicer:
> >
> > (-x)/y == - (x/y)
> But round towards -inf is mathematically nicer:
>
> (x+y)/y = (x/y)+1
>
> And in practice, that's more frequently useful.

Yes. For me the most important advantage is ease of
implementing a ratio rounded to nearest.
Assuming positive y and flooring division it's as simple as
rnd_rat = (2*x + y)/(2*y)
I know of no similarly simple way with truncating division.

However, it seems that in majority of programming/HDL
languages truncating division won.

> >To me the mathematical picture is the more important one.
> People who prefer floored or Euklidean division also give mathematical
> arguments.
>
> - anton
> --
> 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
> Mitch Alsup, <c17fcd89-f024-40e7...@googlegroups.com>

Re: floored vs. symmetric integer division

<2023Jul21.143515@mips.complang.tuwien.ac.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33348&group=comp.arch#33348

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: floored vs. symmetric integer division
Date: Fri, 21 Jul 2023 12:35:15 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 26
Message-ID: <2023Jul21.143515@mips.complang.tuwien.ac.at>
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <b233aab2-c5ff-465b-aace-a89aefcaab3dn@googlegroups.com> <27e5453d-c69f-4f1d-9e4f-73c6ebf5829en@googlegroups.com> <lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me> <2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me> <2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com> <2023Jul21.073302@mips.complang.tuwien.ac.at> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com>
Injection-Info: dont-email.me; posting-host="b4083f02a715932b678d428de9f1a4c7";
logging-data="3431647"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18sIRPHaSv52pG76DgW07RK"
Cancel-Lock: sha1:TAQFkY8PWHKUOPukc2zJP/l2VVw=
X-newsreader: xrn 10.11
 by: Anton Ertl - Fri, 21 Jul 2023 12:35 UTC

Michael S <already5chosen@yahoo.com> writes:
>However, it seems that in majority of programming/HDL
>languages truncating division won.

I don't have an easy way to count the entries in the table at
<https://en.wikipedia.org/wiki/Modulo#In_programming_languages>, but
it seems to me that a lot of languages offer several options:
Truncated (symmetric) and one of floored or Euclidean (which produce
the same results for positive divisors); some only offer truncated,
but some also offer only floored (APL, COBOL, J, LibreOffice, Lua 5,
Mathcad, Mathematica, Excel, MiniTab, MUMPS, PL/1, R, Raku, Scratch,
Snap!, Spin, Solidity, Tcl, Turing) or only Euclidean (ABAP, Algol 68,
PureScript, Stata, Z3).

[Tim Rentsch:]
>> >To me the mathematical picture is the more important one.

It's interesting that the more mathematically-oriented languages like
APL, J, Mathcad, Mathematica, R, and Z3 don't even provide truncated
remainder, so I guess that the "mathematical picture" argues against
truncated (round-towards-0) division.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: floored vs. symmetric integer division

<4560eff6-4d6b-4894-82bb-ad9e6a08ba8an@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33349&group=comp.arch#33349

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:48c:b0:76a:e5e4:17da with SMTP id 12-20020a05620a048c00b0076ae5e417damr1054qkr.5.1689946774531;
Fri, 21 Jul 2023 06:39:34 -0700 (PDT)
X-Received: by 2002:a4a:3794:0:b0:569:a35b:1bcd with SMTP id
r142-20020a4a3794000000b00569a35b1bcdmr3588469oor.1.1689946774202; Fri, 21
Jul 2023 06:39:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 21 Jul 2023 06:39:33 -0700 (PDT)
In-Reply-To: <2023Jul21.143515@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:2df4:e81f:b2d4:e4df;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:2df4:e81f:b2d4:e4df
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com>
<b233aab2-c5ff-465b-aace-a89aefcaab3dn@googlegroups.com> <27e5453d-c69f-4f1d-9e4f-73c6ebf5829en@googlegroups.com>
<lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me>
<2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me>
<2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com>
<2023Jul21.073302@mips.complang.tuwien.ac.at> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com>
<2023Jul21.143515@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4560eff6-4d6b-4894-82bb-ad9e6a08ba8an@googlegroups.com>
Subject: Re: floored vs. symmetric integer division
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Fri, 21 Jul 2023 13:39:34 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3591
 by: Michael S - Fri, 21 Jul 2023 13:39 UTC

On Friday, July 21, 2023 at 4:09:35 PM UTC+3, Anton Ertl wrote:
> Michael S <already...@yahoo.com> writes:
> >However, it seems that in majority of programming/HDL
> >languages truncating division won.
> I don't have an easy way to count the entries in the table at
> <https://en.wikipedia.org/wiki/Modulo#In_programming_languages>, but
> it seems to me that a lot of languages offer several options:
> Truncated (symmetric) and one of floored or Euclidean (which produce
> the same results for positive divisors); some only offer truncated,
> but some also offer only floored (APL, COBOL, J, LibreOffice, Lua 5,
> Mathcad, Mathematica, Excel, MiniTab, MUMPS, PL/1, R, Raku, Scratch,
> Snap!, Spin, Solidity, Tcl, Turing) or only Euclidean (ABAP, Algol 68,
> PureScript, Stata, Z3).
>
> [Tim Rentsch:]
> >> >To me the mathematical picture is the more important one.
> It's interesting that the more mathematically-oriented languages like
> APL, J, Mathcad, Mathematica, R, and Z3 don't even provide truncated
> remainder, so I guess that the "mathematical picture" argues against
> truncated (round-towards-0) division.
> - anton
> --
> 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
> Mitch Alsup, <c17fcd89-f024-40e7...@googlegroups.com>

I never used any of those languages . There is non-zero chance that I'd
learn R eventually. For the rest of them, I don't see a reason.
The only "mathematically-oriented" language that I use regularly (daily) is
Matlab/Octave. It seems that Matlab does not have integer division operation
at all. In Octave it can be achieved although I'd guess that majority of users
are not aware of that. It is truncating which is not surprising given Fortran
heritage of Matlab and Fortran/C heritage of Octave.

Re: floored vs. symmetric integer division

<2023Jul21.162648@mips.complang.tuwien.ac.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33357&group=comp.arch#33357

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: floored vs. symmetric integer division
Date: Fri, 21 Jul 2023 14:26:48 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 17
Message-ID: <2023Jul21.162648@mips.complang.tuwien.ac.at>
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me> <2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me> <2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com> <2023Jul21.073302@mips.complang.tuwien.ac.at> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com> <2023Jul21.143515@mips.complang.tuwien.ac.at> <4560eff6-4d6b-4894-82bb-ad9e6a08ba8an@googlegroups.com>
Injection-Info: dont-email.me; posting-host="b4083f02a715932b678d428de9f1a4c7";
logging-data="3457115"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vtQqzZj4VtbAW9ZseTffE"
Cancel-Lock: sha1:0GjGqoqstWitgo8GtlCS26S4YT0=
X-newsreader: xrn 10.11
 by: Anton Ertl - Fri, 21 Jul 2023 14:26 UTC

Michael S <already5chosen@yahoo.com> writes:
>On Friday, July 21, 2023 at 4:09:35=E2=80=AFPM UTC+3, Anton Ertl wrote:
>> <https://en.wikipedia.org/wiki/Modulo#In_programming_languages>, but=20
....
>The only "mathematically-oriented" language that I use regularly (daily) is=
>=20
>Matlab/Octave. It seems that Matlab does not have integer division operatio=
>n
>at all.

According to the page above, MATLAB has mod (floored) and rem
(truncated). Octave is not listed.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: floored vs. symmetric integer division

<a08a03c5-095a-4688-b6a0-ab8e068c8995n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33362&group=comp.arch#33362

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:b4c7:0:b0:767:dcda:b2f9 with SMTP id d190-20020a37b4c7000000b00767dcdab2f9mr1301qkf.11.1689955358559;
Fri, 21 Jul 2023 09:02:38 -0700 (PDT)
X-Received: by 2002:a05:6870:e148:b0:1b0:19a6:2577 with SMTP id
z8-20020a056870e14800b001b019a62577mr3824937oaa.3.1689955358162; Fri, 21 Jul
2023 09:02:38 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Fri, 21 Jul 2023 09:02:37 -0700 (PDT)
In-Reply-To: <2023Jul21.162648@mips.complang.tuwien.ac.at>
Injection-Info: google-groups.googlegroups.com; posting-host=2a0d:6fc2:55b0:ca00:2df4:e81f:b2d4:e4df;
posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 2a0d:6fc2:55b0:ca00:2df4:e81f:b2d4:e4df
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com>
<lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me>
<2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me>
<2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com>
<2023Jul21.073302@mips.complang.tuwien.ac.at> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com>
<2023Jul21.143515@mips.complang.tuwien.ac.at> <4560eff6-4d6b-4894-82bb-ad9e6a08ba8an@googlegroups.com>
<2023Jul21.162648@mips.complang.tuwien.ac.at>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a08a03c5-095a-4688-b6a0-ab8e068c8995n@googlegroups.com>
Subject: Re: floored vs. symmetric integer division
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Fri, 21 Jul 2023 16:02:38 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Michael S - Fri, 21 Jul 2023 16:02 UTC

On Friday, July 21, 2023 at 5:31:11 PM UTC+3, Anton Ertl wrote:
> Michael S <already...@yahoo.com> writes:
> >On Friday, July 21, 2023 at 4:09:35=E2=80=AFPM UTC+3, Anton Ertl wrote:
> >> <https://en.wikipedia.org/wiki/Modulo#In_programming_languages>, but=20
> ...
> >The only "mathematically-oriented" language that I use regularly (daily) is=
> >=20
> >Matlab/Octave. It seems that Matlab does not have integer division operatio=
> >n
> >at all.
>
> According to the page above, MATLAB has mod (floored) and rem
> (truncated). Octave is not listed.
> - anton
> --
> 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
> Mitch Alsup, <c17fcd89-f024-40e7...@googlegroups.com>

Matlab (and Octave) rem() and mod() are floating point operations rather
than integer.

Re: floored vs. symmetric integer division

<2023Jul21.181656@mips.complang.tuwien.ac.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33364&group=comp.arch#33364

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: floored vs. symmetric integer division
Date: Fri, 21 Jul 2023 16:16:56 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 24
Message-ID: <2023Jul21.181656@mips.complang.tuwien.ac.at>
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <tvduid$fkmb$1@dont-email.me> <2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com> <2023Jul21.073302@mips.complang.tuwien.ac.at> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com> <2023Jul21.143515@mips.complang.tuwien.ac.at> <4560eff6-4d6b-4894-82bb-ad9e6a08ba8an@googlegroups.com> <2023Jul21.162648@mips.complang.tuwien.ac.at> <a08a03c5-095a-4688-b6a0-ab8e068c8995n@googlegroups.com>
Injection-Info: dont-email.me; posting-host="b4083f02a715932b678d428de9f1a4c7";
logging-data="3501560"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX198EcOGC09KTGAs+1tsLg+T"
Cancel-Lock: sha1:rYLptB3LeJJMz65zLb2xtYWFTw8=
X-newsreader: xrn 10.11
 by: Anton Ertl - Fri, 21 Jul 2023 16:16 UTC

Michael S <already5chosen@yahoo.com> writes:
>On Friday, July 21, 2023 at 5:31:11=E2=80=AFPM UTC+3, Anton Ertl wrote:
>> Michael S <already...@yahoo.com> writes:=20
>> >On Friday, July 21, 2023 at 4:09:35=3DE2=3D80=3DAFPM UTC+3, Anton Ertl w=
>rote:=20
>> >> <https://en.wikipedia.org/wiki/Modulo#In_programming_languages>
....
>> According to the page above, MATLAB has mod (floored) and rem=20
>> (truncated). Octave is not listed.
....
>Matlab (and Octave) rem() and mod() are floating point operations rather
>than integer.=20

The page above is not limited to integer operations. And neither is
the issue at hand: is the quotient rounded towards 0 or towards -inf.

However, the page above lists the MATLAB mod and rem as integer, not
floating-point operations. As a MATLAB user you may want to correct
this (and maybe add Octave).

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: floored vs. symmetric integer division

<u9er37$klj$1@gal.iecc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33377&group=comp.arch#33377

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.cmpublishers.com!adore2!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: johnl@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: floored vs. symmetric integer division
Date: Fri, 21 Jul 2023 20:50:47 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <u9er37$klj$1@gal.iecc.com>
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <86mszqxo3n.fsf@linuxsc.com> <2023Jul21.073302@mips.complang.tuwien.ac.at> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com>
Injection-Date: Fri, 21 Jul 2023 20:50:47 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="21171"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <86mszqxo3n.fsf@linuxsc.com> <2023Jul21.073302@mips.complang.tuwien.ac.at> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Fri, 21 Jul 2023 20:50 UTC

According to Michael S <already5chosen@yahoo.com>:
>However, it seems that in majority of programming/HDL
>languages truncating division won.

I suspect that's an ancient artifact of Fortran originally being
implemented on a machine that did (mostly) sign-magnitude arithmetic.

I also suspect too many programming language designers don't know
enough about numerical analysis to make an informed choice between the
two.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: floored vs. symmetric integer division

<2023Jul22.082207@mips.complang.tuwien.ac.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33383&group=comp.arch#33383

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: floored vs. symmetric integer division
Date: Sat, 22 Jul 2023 06:22:07 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 52
Message-ID: <2023Jul22.082207@mips.complang.tuwien.ac.at>
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <86mszqxo3n.fsf@linuxsc.com> <2023Jul21.073302@mips.complang.tuwien.ac.at> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com> <u9er37$klj$1@gal.iecc.com>
Injection-Info: dont-email.me; posting-host="aa88f19e2a28d1c72f6b73c25f683898";
logging-data="3926548"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/VjdU0cqXO8M7bzAN+BHfC"
Cancel-Lock: sha1:z1LVsYoOdqzjuAwWOKNlnDmVPDg=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 22 Jul 2023 06:22 UTC

John Levine <johnl@taugh.com> writes:
>According to Michael S <already5chosen@yahoo.com>:
>>However, it seems that in majority of programming/HDL
>>languages truncating division won.
>
>I suspect that's an ancient artifact of Fortran originally being
>implemented on a machine that did (mostly) sign-magnitude arithmetic.

I suspect so, too. So there's an interesting sequence of events:

* Early architectures used sign-magnitude, where truncated/symmetric
division is easiest to implement, and therefore they implemented
symmetric division.

* Fortran wanted to be close to the machine, and therefore also
implemented truncated division.

* So when architectures switched to two's complement, where floored is
not harder to implement than truncated, those who implemented signed
division implemented truncated division for Fortran compatibility.

It's interesting that COBOL and APL, both from the time before the
switch to 2s-complement, implement floored division according to
<https://en.wikipedia.org/wiki/Modulo#In_programming_languages>

>I also suspect too many programming language designers don't know
>enough about numerical analysis to make an informed choice between the
>two.

Forth is an interesting case:

In the Forth-79 standard the division words /, MOD and /MOD are
defined as "round towards 0" (i.e., truncated).

Forth-83 defined division to be floored.

Finally, since Forth-94, it's up to the implementation whether /, MOD,
and /MOD are floored or symmetric (truncated); basically this means
that in portable programs you better use these words only with
positive operands (and that's probably what the majority of uses were
earlier). If you want to write reliable code where the operands can
have different signs, Forth-94 provides FM/MOD (floored) and SM/REM
(symmetric/truncated).

There is also UM/MOD (unsigned) and some implementations have IIRC a
signed/unsigned division, but I don't remember whether they implement
it symmetric or floored.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: floored vs. symmetric integer division

<u9hd3q$1693$1@gal.iecc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33411&group=comp.arch#33411

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.cmpublishers.com!adore2!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: johnl@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: floored vs. symmetric integer division
Date: Sat, 22 Jul 2023 20:10:34 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <u9hd3q$1693$1@gal.iecc.com>
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com> <u9er37$klj$1@gal.iecc.com> <2023Jul22.082207@mips.complang.tuwien.ac.at>
Injection-Date: Sat, 22 Jul 2023 20:10:34 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="39203"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com> <u9er37$klj$1@gal.iecc.com> <2023Jul22.082207@mips.complang.tuwien.ac.at>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Sat, 22 Jul 2023 20:10 UTC

According to Anton Ertl <anton@mips.complang.tuwien.ac.at>:
>>I suspect that's an ancient artifact of Fortran originally being
>>implemented on a machine that did (mostly) sign-magnitude arithmetic.
>
>I suspect so, too. So there's an interesting sequence of events: ...
>It's interesting that COBOL and APL, both from the time before the
>switch to 2s-complement, implement floored division according to
><https://en.wikipedia.org/wiki/Modulo#In_programming_languages>

For APL it's not surprising. Ken Iverson was a mathematician before he
switched to computing in 1951 working with Howard Aiken and Wassily
Leontief. (If I'd had a chance to work them them, I'd have switched too.)

APL was originally just a paper algorithm language, and wasn't
implemented until several years after Iverson's book came out. So it's
not surprising that it's defined in a way that makes sense mathematically.

The 1960 COBOL report says that "The least significant digit of the
result field will be increased by 1 whenever the most significant
digit of the excess is greater than or equal to 5." unless you say
UNROUNDED in which case it's truncated. Bitsavers is a bit spase on
COBOL but a 1976 IBM DOS COBOL manual says the same thing, with no
mention of a MOD function. Dunno where it came from.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: floored vs. symmetric integer division

<867cqrt64r.fsf@linuxsc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33420&group=comp.arch#33420

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17687@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: floored vs. symmetric integer division
Date: Sun, 23 Jul 2023 00:54:28 -0700
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <867cqrt64r.fsf@linuxsc.com>
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <be0234cc-6ce9-4534-b601-e43ae2d4aaeen@googlegroups.com> <bOlQL.1586560$9sn9.355216@fx17.iad> <b233aab2-c5ff-465b-aace-a89aefcaab3dn@googlegroups.com> <27e5453d-c69f-4f1d-9e4f-73c6ebf5829en@googlegroups.com> <lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me> <2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me> <2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com> <2023Jul21.073302@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="978ba9513973d7ae87a57600d2a2537b";
logging-data="220198"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yjBpza7b8kc5OWGCk3elJyllBdQKJ4sc="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:McaJEgUQJFliIcjgEO+K2pSNU34=
sha1:y3lmOLFJHVhmpLpYSFU3aJ8STGI=
 by: Tim Rentsch - Sun, 23 Jul 2023 07:54 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>
>> anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>
> [floored division]
>
>>> Because it has much nicer behaviour when the dividend crosses 0
>>> than round-towards-0 has:
>>>
>>> round-towards-0 (aka truncated):
>>>
>>> https://en.wikipedia.org/wiki/File:Divmod_truncated.svg
>>>
>>> round towards -inf (floored):
>>>
>>> https://en.wikipedia.org/wiki/File:Divmod_floored.svg
>>
>> Nicer behavior is in the eye of the beholder.
>>
>> The graph for round towards -inf may look more pleasing to
>> the eye.
>>
>> But round towards zero is mathematically nicer:
>>
>> (-x)/y == - (x/y)
>
> But round towards -inf is mathematically nicer:
>
> (x+y)/y = (x/y)+1

Doesn't look nicer to me.

> And in practice, that's more frequently useful.

I dispute that assertion.

>> To me the mathematical picture is the more important one.
>
> People who prefer floored or Euklidean division also give
> mathematical arguments.

No doubt there exist environments where either is more
convenient. In my experience in the programming
domain, rounding towards zero is more consistent
with the law of least astonishment.

Re: floored vs. symmetric integer division

<86351ft5py.fsf@linuxsc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33421&group=comp.arch#33421

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17687@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.arch
Subject: Re: floored vs. symmetric integer division
Date: Sun, 23 Jul 2023 01:03:21 -0700
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <86351ft5py.fsf@linuxsc.com>
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com> <b233aab2-c5ff-465b-aace-a89aefcaab3dn@googlegroups.com> <27e5453d-c69f-4f1d-9e4f-73c6ebf5829en@googlegroups.com> <lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me> <2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me> <2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com> <2023Jul21.073302@mips.complang.tuwien.ac.at> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com> <2023Jul21.143515@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="978ba9513973d7ae87a57600d2a2537b";
logging-data="220198"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/myEQlZtcLQjrvUyKdlJZvGusO7qMXJ5A="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:WGI3PoXai7CEHWbfNWrt5yTQfCw=
sha1:D+g9sTZprnY0kuwZeGL6XkkOuvw=
 by: Tim Rentsch - Sun, 23 Jul 2023 08:03 UTC

anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:

> [Tim Rentsch:]
>
>>>> To me the mathematical picture is the more important one.
>
> It's interesting that the more mathematically-oriented languages
> like APL, J, Mathcad, Mathematica, R, and Z3 don't even provide
> truncated remainder, so I guess that the "mathematical picture"
> argues against truncated (round-towards-0) division.

It's interesting that in C90 which way division worked was
allowed to be implementation defined, but in C99 and later
division is required to be truncating division.

(For integers, of course. Floating point is another story
altogether.)

Re: floored vs. symmetric integer division

<58773752-b762-4c29-93ae-5528aee0f82en@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33423&group=comp.arch#33423

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a37:2c46:0:b0:762:4134:c1be with SMTP id s67-20020a372c46000000b007624134c1bemr15598qkh.9.1690115415681;
Sun, 23 Jul 2023 05:30:15 -0700 (PDT)
X-Received: by 2002:a05:6808:1790:b0:3a2:4d1d:2831 with SMTP id
bg16-20020a056808179000b003a24d1d2831mr13288539oib.3.1690115415317; Sun, 23
Jul 2023 05:30:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sun, 23 Jul 2023 05:30:15 -0700 (PDT)
In-Reply-To: <4560eff6-4d6b-4894-82bb-ad9e6a08ba8an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com>
<b233aab2-c5ff-465b-aace-a89aefcaab3dn@googlegroups.com> <27e5453d-c69f-4f1d-9e4f-73c6ebf5829en@googlegroups.com>
<lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me>
<2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me>
<2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com>
<2023Jul21.073302@mips.complang.tuwien.ac.at> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com>
<2023Jul21.143515@mips.complang.tuwien.ac.at> <4560eff6-4d6b-4894-82bb-ad9e6a08ba8an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <58773752-b762-4c29-93ae-5528aee0f82en@googlegroups.com>
Subject: Re: floored vs. symmetric integer division
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Sun, 23 Jul 2023 12:30:15 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4165
 by: Michael S - Sun, 23 Jul 2023 12:30 UTC

On Friday, July 21, 2023 at 4:39:36 PM UTC+3, Michael S wrote:
> On Friday, July 21, 2023 at 4:09:35 PM UTC+3, Anton Ertl wrote:
> > Michael S <already...@yahoo.com> writes:
> > >However, it seems that in majority of programming/HDL
> > >languages truncating division won.
> > I don't have an easy way to count the entries in the table at
> > <https://en.wikipedia.org/wiki/Modulo#In_programming_languages>, but
> > it seems to me that a lot of languages offer several options:
> > Truncated (symmetric) and one of floored or Euclidean (which produce
> > the same results for positive divisors); some only offer truncated,
> > but some also offer only floored (APL, COBOL, J, LibreOffice, Lua 5,
> > Mathcad, Mathematica, Excel, MiniTab, MUMPS, PL/1, R, Raku, Scratch,
> > Snap!, Spin, Solidity, Tcl, Turing) or only Euclidean (ABAP, Algol 68,
> > PureScript, Stata, Z3).
> >
> > [Tim Rentsch:]
> > >> >To me the mathematical picture is the more important one.
> > It's interesting that the more mathematically-oriented languages like
> > APL, J, Mathcad, Mathematica, R, and Z3 don't even provide truncated
> > remainder, so I guess that the "mathematical picture" argues against
> > truncated (round-towards-0) division.
> > - anton
> > --
> > 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
> > Mitch Alsup, <c17fcd89-f024-40e7...@googlegroups.com>
> I never used any of those languages . There is non-zero chance that I'd
> learn R eventually. For the rest of them, I don't see a reason.
> The only "mathematically-oriented" language that I use regularly (daily) is
> Matlab/Octave. It seems that Matlab does not have integer division operation
> at all. In Octave it can be achieved although I'd guess that majority of users
> are not aware of that. It is truncating which is not surprising given Fortran
> heritage of Matlab and Fortran/C heritage of Octave.

Above I was wrong.
After closer examination I understood that there is no difference between Matlab
and Octave scripts - integer division is absent in both of them.
What I originally confused for integer division in Octave was in fact a floating point
(binary64) division followed by rounding of result to nearest integer with ties broken
away from zero.

Re: floored vs. symmetric integer division

<29d44da7-b816-4c7c-aac7-ad9ed840a9e9n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33424&group=comp.arch#33424

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:6214:186e:b0:63c:edce:c71e with SMTP id eh14-20020a056214186e00b0063cedcec71emr25822qvb.3.1690117308917;
Sun, 23 Jul 2023 06:01:48 -0700 (PDT)
X-Received: by 2002:a9d:7352:0:b0:6b9:b1b8:bf0b with SMTP id
l18-20020a9d7352000000b006b9b1b8bf0bmr5220237otk.0.1690117308569; Sun, 23 Jul
2023 06:01:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sun, 23 Jul 2023 06:01:48 -0700 (PDT)
In-Reply-To: <58773752-b762-4c29-93ae-5528aee0f82en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com>
<b233aab2-c5ff-465b-aace-a89aefcaab3dn@googlegroups.com> <27e5453d-c69f-4f1d-9e4f-73c6ebf5829en@googlegroups.com>
<lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me>
<2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me>
<2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com>
<2023Jul21.073302@mips.complang.tuwien.ac.at> <e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com>
<2023Jul21.143515@mips.complang.tuwien.ac.at> <4560eff6-4d6b-4894-82bb-ad9e6a08ba8an@googlegroups.com>
<58773752-b762-4c29-93ae-5528aee0f82en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <29d44da7-b816-4c7c-aac7-ad9ed840a9e9n@googlegroups.com>
Subject: Re: floored vs. symmetric integer division
From: already5chosen@yahoo.com (Michael S)
Injection-Date: Sun, 23 Jul 2023 13:01:48 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4927
 by: Michael S - Sun, 23 Jul 2023 13:01 UTC

On Sunday, July 23, 2023 at 3:30:17 PM UTC+3, Michael S wrote:
> On Friday, July 21, 2023 at 4:39:36 PM UTC+3, Michael S wrote:
> > On Friday, July 21, 2023 at 4:09:35 PM UTC+3, Anton Ertl wrote:
> > > Michael S <already...@yahoo.com> writes:
> > > >However, it seems that in majority of programming/HDL
> > > >languages truncating division won.
> > > I don't have an easy way to count the entries in the table at
> > > <https://en.wikipedia.org/wiki/Modulo#In_programming_languages>, but
> > > it seems to me that a lot of languages offer several options:
> > > Truncated (symmetric) and one of floored or Euclidean (which produce
> > > the same results for positive divisors); some only offer truncated,
> > > but some also offer only floored (APL, COBOL, J, LibreOffice, Lua 5,
> > > Mathcad, Mathematica, Excel, MiniTab, MUMPS, PL/1, R, Raku, Scratch,
> > > Snap!, Spin, Solidity, Tcl, Turing) or only Euclidean (ABAP, Algol 68,
> > > PureScript, Stata, Z3).
> > >
> > > [Tim Rentsch:]
> > > >> >To me the mathematical picture is the more important one.
> > > It's interesting that the more mathematically-oriented languages like
> > > APL, J, Mathcad, Mathematica, R, and Z3 don't even provide truncated
> > > remainder, so I guess that the "mathematical picture" argues against
> > > truncated (round-towards-0) division.
> > > - anton
> > > --
> > > 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
> > > Mitch Alsup, <c17fcd89-f024-40e7...@googlegroups.com>
> > I never used any of those languages . There is non-zero chance that I'd
> > learn R eventually. For the rest of them, I don't see a reason.
> > The only "mathematically-oriented" language that I use regularly (daily) is
> > Matlab/Octave. It seems that Matlab does not have integer division operation
> > at all. In Octave it can be achieved although I'd guess that majority of users
> > are not aware of that. It is truncating which is not surprising given Fortran
> > heritage of Matlab and Fortran/C heritage of Octave.
> Above I was wrong.
> After closer examination I understood that there is no difference between Matlab
> and Octave scripts - integer division is absent in both of them.
> What I originally confused for integer division in Octave was in fact a floating point
> (binary64) division followed by rounding of result to nearest integer with ties broken
> away from zero.

More experiments proved that what I said above is also incorrect.
64-bit integer numbers are not converted to IEEE binary64 floats before division.
They somehow preserve all bits of precision. So, it seems that both Matlab and Octave
do have integer division after all or at least something that is very similar to integer division.
And result of division is rounded to nearest with ties broken away from zero.

Re: floored vs. symmetric integer division

<u9jd0e$152s0$1@newsreader4.netcologne.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=33427&group=comp.arch#33427

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd6-29be-0-d4b3-d5ba-bfb8-68f2.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch
Subject: Re: floored vs. symmetric integer division
Date: Sun, 23 Jul 2023 14:21:02 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <u9jd0e$152s0$1@newsreader4.netcologne.de>
References: <364aaeda-907d-4187-b2b3-3c6238b4ad9en@googlegroups.com>
<b233aab2-c5ff-465b-aace-a89aefcaab3dn@googlegroups.com>
<27e5453d-c69f-4f1d-9e4f-73c6ebf5829en@googlegroups.com>
<lJ1RL.1034307$MVg8.486995@fx12.iad> <tv9k8d$3fig8$2@dont-email.me>
<2023Mar20.152034@mips.complang.tuwien.ac.at> <tvduid$fkmb$1@dont-email.me>
<2023Mar22.185044@mips.complang.tuwien.ac.at> <86mszqxo3n.fsf@linuxsc.com>
<2023Jul21.073302@mips.complang.tuwien.ac.at>
<e8648f10-a79b-42bc-95bf-30f875a376ffn@googlegroups.com>
<2023Jul21.143515@mips.complang.tuwien.ac.at>
<4560eff6-4d6b-4894-82bb-ad9e6a08ba8an@googlegroups.com>
<58773752-b762-4c29-93ae-5528aee0f82en@googlegroups.com>
<29d44da7-b816-4c7c-aac7-ad9ed840a9e9n@googlegroups.com>
Injection-Date: Sun, 23 Jul 2023 14:21:02 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd6-29be-0-d4b3-d5ba-bfb8-68f2.ipv6dyn.netcologne.de:2001:4dd6:29be:0:d4b3:d5ba:bfb8:68f2";
logging-data="1215360"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 23 Jul 2023 14:21 UTC

Michael S <already5chosen@yahoo.com> schrieb:

> 64-bit integer numbers are not converted to IEEE binary64 floats before division.
> They somehow preserve all bits of precision. So, it seems that both Matlab and Octave
> do have integer division after all or at least something that is very similar to integer division.
> And result of division is rounded to nearest with ties broken away from zero.

A weird mixture between floating point and integer arithmetic...

What would be the right term for that, maybe "floppy point arithmetic"?

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor