[General] Fixed width, minimum width and fastest minimum width unsigned 8 bit integer

Status
Not open for further replies.

shaswat

Advanced Member level 4
Joined
Jul 2, 2013
Messages
115
Helped
1
Reputation
2
Reaction score
1
Trophy points
18
Activity points
963
Hi All,

Last night I read an article on choosing correct integer size https://embeddedgurus.com/stack-overflow/2008/06/efficient-c-tips-1-choosing-the-correct-integer-size/. Before reading this article, I was unaware of these three keywords. These keywords are:

1) Fixed width unsigned 8-bit integer: uint8_t. (Keywords are C99 complaints)

2) Minimum width unsigned 8-bit integer: uint_least8_t.

3) Fastest minimum width unsigned 8-bit integer: uint_fast8_t.

So my question are:

1) What exactly they mean by saying "at least 8 bits wide" for uint_least8_t & uint_fast8_t. For example, let's take a look of snippet of code

Code:
                    for(u16 i=0;i<counter;i++)
                    {
                      Increment_Counter++;
                    }

When counter =0xFF; Increment_Counter will work fine by any type of keyword declaration.
Now when counter =0x01FF; what kind of declaration should I choose? uint_least8_t (who guaranteed to be at least 8 bits wide) or unit16 type?



1) How choosing uint_fast8_t affects the code speed.

2) How choosing uint_least8_t consumes lesser data memory than unsigned char.


Thanks in advance
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…