Is integer overflow defined?

Sean Eskapp eatingstaples at gmail.com
Thu Sep 1 11:04:00 PDT 2011


== Quote from Timon Gehr (timon.gehr at gmx.ch)'s article
> On 09/01/2011 06:20 PM, Sean Eskapp wrote:
> > Is integer overflow defined (for instance, as being mod 2^size)?
> I am quite sure that all operations are defined as operations on two's
> complement integers, which would mean overflow is defined, but I cannot
> find the respective part of the specification...
>  > Can I reliably say that -long.min == 0L?
> Well no, -long.min == long.min .
> according to TDPL p53., that fact is defined. (unary minus: -x == ~x+1)

Ah, good points, thanks!


More information about the Digitalmars-d-learn mailing list