Comment #0 by bearophile_hugs — 2013-08-03T03:22:23Z
void main() {
uint x = 6;
char digit1 = (x % 10) + '0'; // OK
char digit2 = (x < 10) ? (x + '0') : '#'; // Error.
}
DMD 2.064alpha gives:
test.d(4): Error: cannot implicitly convert expression (x < 10u ? x + 48u : 35u) of type uint to char
I think the line with digit2 should compile.
(Every useless cast removed from the code reduces the chance of bugs).
Comment #1 by robert.schadek — 2024-12-13T18:10:00Z