Article View: comp.arch
Article #1119Re: reassociation and undefined behaviour
From: Waldek Hebisch
Date: Sun, 06 Dec 2026 00:25
Date: Sun, 06 Dec 2026 00:25
34 lines
2940 bytes
2940 bytes
MitchAlsup <user5857@newsgrouper.org.invalid> wrote:
> antispam@fricas.org (Waldek Hebisch) posted:
>
>> EricP <ThatWouldBeTelling@thevillage.com> wrote:
>> > On 2026-Dec-04 12:11, Thomas Koenig wrote:
>> >> EricP <ThatWouldBeTelling@thevillage.com> schrieb:
>> >>> On 2026-Dec-04 03:35, David Brown wrote:
>> >>>> On 03/12/2026 20:43, MitchAlsup wrote:
>> >>>>
>> >>>> So it is useful in the same way that two's complement wrapping for signed arithmetic is useful - it is absolutely absurd mathematically that you can add two positive numbers and get a negative one, there is almost certainly a bug in your program if this happens in general code, but it matches the hardware, is often harmless, and it is occasionally handy.
>> >>>
>> >>> Why is signed twos's complement wrapping mathematically absurd?
>> >>
>> >> If you add enough apples to a pile, the number of apples becomes
>> >> negative (to quote Dan Brown ;-)
>> >>
>> >
>> > How is that different than wrapping from positive down to zero?
>> > That's just how modulo arithmetic works.
>>
>> Both are equally wrong if you need integers. The difference is
>> that if you need integers than signed is a natural choice.
>> Unsigned is for special cases, so it gets less attention.
>
> I rarely use any signed integers--signed is for values that HAVE
> TO ALLOW a negative value representation. These are few and far
> between when writing CPU simulators. Something close to 99% of my
> ints are unsigned.
CPU simulators clearly are a special case. Still, I would
expect slightly higher use of signed.
--
Waldek Hebisch
Technical Details
Message-ID:
<11f2a2h$62u8$2@paganini.bofh.team>Path:
mbox-mo1.pugleaf.net!news-fra.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!paganini.bofh.team!not-for-mailReferences:
<11cpqih$acf5$1@dont-email.me> <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> <11eus8u$1q9ee$1@dont-email.me> <gmDQS.352851$ZAo7.329237@fx18.iad> <11f1elt$3r7e$2@paganini.bofh.team> <1796498363-5857@newsgrouper.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!paganini.bofh.team!not-for-mail
From: antispam@fricas.org (Waldek Hebisch)
Newsgroups: comp.arch
Subject: Re: reassociation and undefined behaviour
Date: Sun, 6 Dec 2026 00:25:55 -0000 (UTC)
Organization: bofh.team Usenet service
Message-ID: <11f2a2h$62u8$2@paganini.bofh.team>
References: <11cpqih$acf5$1@dont-email.me> <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> <11eus8u$1q9ee$1@dont-email.me> <gmDQS.352851$ZAo7.329237@fx18.iad> <11f1elt$3r7e$2@paganini.bofh.team> <1796498363-5857@newsgrouper.org>
Injection-Date: Sun, 6 Dec 2026 00:25:55 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="199624"; mail-complaints-to="usenet@bofh.team"; posting-host="d028f9ad2fa2c51f22dbfed0d81d7daf"; posting-account="69e66f1681224ab92235b464ce7a90b6"
User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
X-Postfilter: Postfilter-NG 2026.10.2