O_O
O_O

Reputation: 4477

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

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

Upvotes: 21

Views: 12531

Answers (2)

Jens Gustedt
Jens Gustedt

Reputation: 78903

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.

Upvotes: 10

anon
anon

Reputation:

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

Upvotes: 21

Related Questions