Fixed point processing: what is the difference between uint16_t and uint_fast16_t?

11.6k Views Asked by At

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!!

2

There are 2 best solutions below

6
On BEST ANSWER

uint16_t is an unsigned 16-bit integer. uint_fast16_t is the fastest available unsigned integer with at least 16 bits.

2
On

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.