C / C++ Literals C / C++ Literals c c

C / C++ Literals


The rule is that first the RHS is evaluated, and then the value is converted for the target type. In particular

uint32_t b = a + 5;

is equivalent to

uint32_t b = (uint32_t)((int)a + 5);

If uint16_t is a narrow type, narrower than int.

All operations in C (and I think also in C++) are at least at an integer rank of int.