Checked shift?

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 31 11:08:56 PDT 2014


H. S. Teoh:

> What would you check for? Shifting something that already has 
> its high bit set?

If you have a uint where the 3 most significant bits are 1, and 
you shift it 3 bits on the left, you lose those three bits, you 
have an overflow. The point of checkedint functions/intrinsics is 
to reveal overflows.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list