Why there is too many uneccessary casts?

Simen Kjaeraas simen.kjaras at gmail.com
Tue Jun 11 05:03:04 PDT 2013


On Tue, 11 Jun 2013 13:46:11 +0200, Temtaime <temtaime at gmail.com> wrote:

> No. I means, that
>
> uint a = uint.max;
> uint b = a + 1;
> writeln(b);
>
> Works OK.
> Why? Compiler doesn't know if a + b fits in uint, right?
> Then why overflow with ints are accepted?

Because there's a limit to how far this goes without introducing
arbitrary-precision numbers. There is indeed an argument for uint+uint
giving a ulong answer, and I'm confused myself at why this is not the
case.


> So your example is meaningless.

No.

-- 
Simen


More information about the Digitalmars-d-learn mailing list