Date: Wed, 11 Dec 2019 08:26:46 -0800
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.
Pre-C++17:
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 -
absolute(value).
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)
> 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.
Pre-C++17:
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 -
absolute(value).
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
Received on 2019-12-11 10:29:14