shaswat
Advanced Member level 4
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
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
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