Sujet : Re: What is your opinion about unsigned int u = -2 ?
De : jameskuyper (at) *nospam* alumni.caltech.edu (James Kuyper)
Groupes : comp.lang.cDate : 11. Aug 2024, 21:53:20
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v9b8c0$2sac4$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
On 8/11/24 16:08, Vir Campestris wrote:
...
"Converting -1 to an unsigned type always sets all the bits"
In any normal twos complement architecture that's the case. But there
are a few oddballs out there where -1 is +1, except that the dedicated
sign bit is set.
There may be hardware where that is true, but a conforming
implementation of C targeting that hardware cannot use the hardware's
result. It must fix up the result produced by the hardware to match the
result required by the C standard.