Subject: Re: Validity of conversions between 4 byte-like types (byte, char) objects
From: Thiago Macieira (thiago_at_[hidden])
Date: 2019-12-11 10:26:46
On Wednesday, 11 December 2019 02:42:30 PST Roman Babinicz wrote:
> Mostly I just wanted to confirm - whether my understanding of this text
> is correct.
> I hope that is the valid question on std-discussion group - asking about
> the standard.
Your question is unnecessarily complex and your text is very hard to read.
The integer conversions are very well explained in the standard. Converting
from signed to unsigned is such that any non-negative values retain their
values and any negative ones are represented as TYPE_MAX + 1 -
Conversion from unsigned to signed is such that any value that is
representable in the destination is retained without change and it's
implementation-defined what happens to values out of range.
C++17: (see http://eel.is/c++draft/conv.integral#3)
"the result is the unique value of the destination type that is congruent to
the source integer modulo 2^N, where N is the width of the destination type."
(that is, just two's complement)
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel System Software Products
STD-DISCUSSION list run by firstname.lastname@example.org
Older Archives on Google Groups