Why there is too many uneccessary casts?
bearophile
bearophileHUGS at lycos.com
Tue Jun 11 05:07:41 PDT 2013
Temtaime:
> Why? Compiler doesn't know if a + b fits in uint, right?
> Then why overflow with ints are accepted?
It's an inconstancy based on practical considerations.
Walter decided that applying the same rule to uint/int/long
causes too many casts in normal problems.
And the range of a 32 bit int is much larger than the range of a
ubyte/byte/ushort/short, so in normal programs the probability of
overflowing an int by mistake is much lower than overflowing a
ubyte.
> So your example is meaningless.
You should be more gentle if you want people to keep giving you
answers :-)
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list