🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #1076

Re: arithmetic, was reassociation and undefined behaviour

#1076
From: John Levine
Date: Fri, 04 Dec 2026 18:10
21 lines
2305 bytes
According to David Brown  <david.brown@hesbynett.no>:
>Of course if you want to have a modulo arithmetic system with signed 
>integers of a particular size, two's complement wrapping integers are 
>great (assuming they match the modulo you want!).  But that's not what 
>people usually want to model when they use "int" or similar types in 
>most languages - they want a type that models mathematical integers as 
>well as practically possible with maximally efficient implementations on 
>their hardware.

One's complement and sign-magnitude have symmetrical ranges, but
their implementation is more complicated than two's complement
and they have two versions of zero, +0 and -0 which can also
make code or implementations more complicated.

Having programed a fair number of two's complement computers over
the past 50 years, I never found the fact that there's an extra
negative number at tne end of the range to be a big problem.
-- 
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
Technical Details
Message-ID: <11euvmp$1u6r$2@gal.iecc.com>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
References: <11cpqih$acf5$1@dont-email.me> <TlCQS.44884$7vt4.19168@fx07.iad> <11eus8u$1q9ee$1@dont-email.me> <11euul5$1ritd$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: John Levine <johnl@taugh.com>
Newsgroups: comp.arch
Subject: Re: arithmetic, was reassociation and undefined behaviour
Date: Fri, 4 Dec 2026 18:10:33 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <11euvmp$1u6r$2@gal.iecc.com>
References: <11cpqih$acf5$1@dont-email.me> <TlCQS.44884$7vt4.19168@fx07.iad> <11eus8u$1q9ee$1@dont-email.me> <11euul5$1ritd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 4 Dec 2026 18:10:33 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
	logging-data="63707"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <11cpqih$acf5$1@dont-email.me> <TlCQS.44884$7vt4.19168@fx07.iad> <11eus8u$1q9ee$1@dont-email.me> <11euul5$1ritd$1@dont-email.me>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)