Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: two's complement idea
Date: Sat, 09 Nov 2019 06:24:47 -0800
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <86lfspcekw.fsf@linuxsc.com>
References:
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="bd07fdb0e7610947dc98257bdadc7724"; logging-data="9605"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vKthCqs5EMUZ7keHug+nExiJBA0DCzGY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:gQ9D6flisXDhFBm2Ahn1T/rQbzU= sha1:KZoHZp5gFo2O6JuPi4V/LrTPZ18=
Xref: csiph.com comp.lang.c++:69679
Paavo Helde writes:
> On 5.11.2019 17:58, Bonita Montero wrote:
>
>> With the same reasoning you could say that unsigneds might never
>> wrap; but in fact they're specified to wrap.
>
> In retrospect, this (wrapping unsigneds) looks like a major design mistake.
>
> IMO, wrapping integers (signed or unsigned) are an example of
> "optimization which nobody asked for", and they are there basically
> only because the hardware happened to support such operations.
Apparently you think how the hardware behaves (specifically, for
unsigned or two's complement operands) is some sort of accident
of history. It isn't. It was a deliberate choice, made by smart
people. It isn't just a coincidence that the semantics of
wrapping works nicely in a variety of applications.