In c++, specifically the cstdint header file, there are types for 8-bit integers which turn out to be of the char data type with a typedef. Could anyone suggest an actual 8-bit integer type?
The minimum size for char is 8 bits, the minimum size for short and int is 16 bits, for long it is 32 bits and long long must contain at least 64 bits. The type int should be the integer type that the target processor is most efficiently working with.
Software Engineering C data type Integer is defined as a number which has no fractional component. Numbers which have a fractional component is known floating point numbers.
Yes, you are right. int8_t
and uint8_t
are typedef
to char
on platforms where 1 byte is 8 bits. On platforms where it is not, appropriate definition will be given.
Following answer is based on assumption that char is 8 bits
char
holds 1 byte, which may be signed
or unsigned
based on implementation.
So int8_t
is signed char
and uint8_t
is unsigned char
, but this will be safe to use int8_t/uint8_t as actual 8-bit integer without relying too much on the implementation.
For a implementer's point of view, typedef
fing where char is 8 bits makes sense.
Having seen all this, It is safe to use int8_t
or uint8_t
as real 8 bit integer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With