www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Portability of uint over/underflow behavior

Don:
 What you're calling 'overflow' in unsigned operations is actually the 
 carry flag. The CPU also an overflow flag which applies to signed 
 operations.

I may need to work with numbers that are always >= 0 that can't fit in 63 bits. This has actually happened to me once. A third possible syntax, even more localized (to be used with or instead of the other two possible syntaxes): unsafe uint x = uint.max; uint y = uint.max; x++; // ==> OK, now x == 0 y++; // ==> throws runtime overflow exception Bye, bearophile
Jan 07 2009