Question about iteger literals
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 22 05:07:44 PDT 2014
Uranuz:
> Another stupid question. Using this logic substraction for two
> uint values should return int too, because it can produce
> negative result. Am I right or not?
There are no stupid questions, there are only some stupid answers.
Generally uint - uint generates a result with a [-4_294_967_295,
4__294_967_295] range, that can't fit in an integer.
I think D here makes an exception to its rule, to avoid too many
casts. Because too many casts make the code even less safe than
breaking the range assignments rules.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list