I was a bit messing around with uint8_t
and was curious what happens when I outflow bits to the left and found that
uint8_t i = 234;
uint8_t j = (i << 1);
auto k = (i << 1);
std::cout << (int)j << std::endl;
std::cout << k << std::endl;
prints out
212
468
and not the expected
212
212
It seems like <<
does promote an uint8_t
too some wider integer type. Why does it do this?
Here a link where you see it in action