Question about iteger literals
Uranuz via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jul 20 10:52:42 PDT 2014
> I see these rules but when I compile following code and it
> fails with error it looks VERY stupid.
>
> import std.stdio;
>
> void main()
> {
> ubyte a = 15;
> ubyte b = 10;
>
> ubyte c = a + b; //What is happening there?! AAAAARGH! Are you
> joking?!
>
> }
>
> Compilation output:
> /d837/f382.d(9): Error: cannot implicitly convert expression
> (cast(int)a + cast(int)b) of type int to ubyte
>
> I'm just crazy about it! How could it happen?!
I just should forget about all integer type except *int*, because
it make my head just explode!!!
More information about the Digitalmars-d-learn
mailing list