I have a 16 bit fixed point processor and I want to do fixed point processing with it. I'm looking for the correct datatype to use for unsigned 16 bit ints..
My question is: what is the difference between a uint16_t
and uint_fast16_t
? (These are included in the stdint.h
.) Is uint_fast16_t
better since it is faster??
Thanks!!
int is usually (but may not be) a 32-bit signed integer, while uint16_t is guaranteed to be an unsigned 16-bit integer.
uint16_t is unsigned 16-bit integer. unsigned short int is unsigned short integer, but the size is implementation dependent. The standard only says it's at least 16-bit (i.e, minimum value of UINT_MAX is 65535 ). In practice, it usually is 16-bit, but you can't take that as guaranteed.
uint_least16_t the smallest thing that is capable of holding a uint16. uint_fast16_t the fastest thing that is capable of holding a uint16. uint16_t exactly a uint16, unfortunately may not be available on all platforms, on any platform where is is available uint_least16_t will refer to it.
uint16_t
is an unsigned 16-bit integer. uint_fast16_t
is the fastest available unsigned integer with at least 16 bits.
uint16_t
is more restrictive than uint_fast16_t
and uint_least16_t
. Not only that the later two may be wider than 16 bits, they may also have padding bits (bits that don't account for the value such as parity bits).
This difference is even more pronounced for the signed types. Here the exact width types must use the two's complement to represent negative values.
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