Is integer overflow defined?

Timon Gehr timon.gehr at gmx.ch
Fri Sep 2 03:10:29 PDT 2011


On 09/02/2011 02:45 AM, bearophile wrote:
> Timon Gehr:
>
>> according to TDPL p53., that fact is defined. (unary minus: -x == ~x+1)
>
> Uhmmmm.
>
> Bye,
> bearophile

For unsigned integers it is clearly defined:

1000... => 0111... => 1000...

And according to TDPL p53: "This manipulation does not raise particular 
questions about the signedness of val".

So, it is guaranteed that it will work for long.min .


More information about the Digitalmars-d-learn mailing list