Should % ever "overflow"?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 24 13:33:45 PDT 2016


In a checked environment, division may "overflow", e.g. -6 / 2u must be 
typed as uint but is not representable properly one.

How about remainder? I suppose one can make the argument that remainder 
should never overflow (save for rhs == 0), because it could be defined 
with either a positive or negative denominator (which is not part of the 
result).

What's the most reasonable behavior?


Andrei


More information about the Digitalmars-d mailing list