Why is std::cout not printing the correct value for my int8_t number?

Because int8_t is the same as signed char, and char is not treated as a number by the stream. Cast into e.g. int16_t

std::cout << static_cast<int16_t>(value) << std::endl;

and you’ll get the correct result.

Leave a Comment