Article View: comp.arch
Article #1084Re: reassociation and undefined behaviour
From: Anton Ertl
Date: Fri, 04 Dec 2026 22:06
Date: Fri, 04 Dec 2026 22:06
33 lines
2873 bytes
2873 bytes
EricP <ThatWouldBeTelling@thevillage.com> writes: >On 2026-Dec-04 13:08, Anton Ertl wrote: >> EricP <ThatWouldBeTelling@thevillage.com> writes: >>> I'm not a mathy but is it mathematically not just modulo arithmetic >>> with a relabelling of some values? ... >Yes. But as 0 is a special number, because you can divide any number >by any other number except 0 Note that modern CPUs perform addition, subtraction and multiplication modulo 2^n, but do not follow modular arithmetic rules for division. At all. If it did, with m=2^64 you would get 2/3=0x5555555555555556 because 0x5555555555555556*3 gives 2. Instead, "computer integer" division gives the result of integer division rounded, typically, towards 0. Given that most people use "computer integers" as approximations of integers most of the time (certainly when they divide), this makes sense. >I was wondering if there was something mathematically different >about wrapping from negative to positive symmetrically around zero >vs asymmetrically from zero to positive. My intuition said there should >be no difference but I'm not a mathy so was asking. There is nothing different. - anton -- 'Anyone trying for "industrial quality" ISA should avoid undefined behavior.' Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID:
<2026Dec4.230655@mips.complang.tuwien.ac.at>Path:
mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11cpqih$acf5$1@dont-email.me> <jwvbj74bzm4.fsf-monnier+comp.arch@gnu.org> <11eolqn$2peg5$1@dont-email.me> <2026Dec2.132411@mips.complang.tuwien.ac.at> <11epd07$362ph$1@dont-email.me> <1796263648-5857@newsgrouper.org> <11ergn7$6utu$1@dont-email.me> <2026Dec3.122036@mips.complang.tuwien.ac.at> <1796326998-5857@newsgrouper.org> <11etu0b$1aih9$1@dont-email.me> <TlCQS.44884$7vt4.19168@fx07.iad> <2026Dec4.190839@mips.complang.tuwien.ac.at> <ewEQS.416856$Lt64.284338@fx41.iad>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.arch Subject: Re: reassociation and undefined behaviour Date: Fri, 04 Dec 2026 22:06:55 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 33 Message-ID: <2026Dec4.230655@mips.complang.tuwien.ac.at> References: <11cpqih$acf5$1@dont-email.me> <jwvbj74bzm4.fsf-monnier+comp.arch@gnu.org> <11eolqn$2peg5$1@dont-email.me> <2026Dec2.132411@mips.complang.tuwien.ac.at> <11epd07$362ph$1@dont-email.me> <1796263648-5857@newsgrouper.org> <11ergn7$6utu$1@dont-email.me> <2026Dec3.122036@mips.complang.tuwien.ac.at> <1796326998-5857@newsgrouper.org> <11etu0b$1aih9$1@dont-email.me> <TlCQS.44884$7vt4.19168@fx07.iad> <2026Dec4.190839@mips.complang.tuwien.ac.at> <ewEQS.416856$Lt64.284338@fx41.iad> Injection-Date: Fri, 04 Dec 2026 22:19:27 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2187852"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dTJNpO/DZN4Y3OkMIo90X"; posting-host="2d0b4d6fdd77f388e773fd7f60d00b18" Cancel-Lock: sha1:cEIS+QPONPiMQQGD1sMuLB5dgzc= sha256:XJEi/OMQ6fGPdIHe1PN20jpfnpGhh26b39SjQEJ4duA= sha1:9xLT6DLGoBYSD0J5ZbAs70ffHDw= sha256:oJ45Vaow6uNYpSvTLjzBt4g4Q07ZMHZ8dZEu+FqBVRE= X-newsreader: xrn 10.11