Question about iteger literals
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 22 04:27:23 PDT 2014
Uranuz:
> But I don't understand why in expression where both of
> arguments have type char:
> return c - '0';
> I have resulting type int. It's very strange for me and looks
> very buggy)
In D operations among chars return a int. The same happens in
C/C++.
If you subtract a char from a char in general you can have a
negative result, that can't fit in a char. So what's buggy is
your thinking.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list