Question about iteger literals

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 20 10:58:58 PDT 2014


Uranuz:

> 	ubyte a = 15;
> 	ubyte b = 10;
> 	
> 	ubyte c = a + b; //What is happening there?! AAAAARGH! Are you 
> joking?!

In C/C++/D if you sum a types that are smaller than int, you 
obtain an int. D has copied C for backwards compatibility with C 
code.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list