You can decipher most of them yourself.
- A
u
prefix means unsigned
.
- The number is the number of bits used. There's 8 bits to the byte.
- The
_t
means it's a typedef
.
So a uint8_t
is an unsigned 8 bit value, so it takes 1 byte. A uint16_t
is an unsigned 16 bit value, so it takes 2 bytes (16/8 = 2)
The only fuzzy one is int
. That is "a signed integer value at the native size for the compiler". On an 8-bit system like the ATMega chips that is 16 bits, so 2 bytes. On 32-bit systems, like the ARM based Due, it's 32 bits, so 4 bytes. Of the three it is the only one that changes.
Personally I rarely use int
and always use uint8_t
etc., since the variable type is the same no matter what architecture you compile for. When you use int
you can run into problems if you had a program that worked fine on a 32-bit ARM but then doesn't work right on an 8-bit ATMega, since the int
can only store a fraction of the range of numbers on the 8-bit system compared to the 32-bit system.
int
. E.g.(uint8_t) 200 + (uint8_t) 200
does not overflow: the terms are promoted toint
before the addition and the result is(int) 400
.