user27157: This question is quite clear. What are the differences between an int, an uint8_t, and an uint16_t. I know it has to do with bytes and memory but can someone clarify me a bit?
Things I want to know:
1- How much memory does each take.
2- When to use what.
3- In the end of the day, are they that different?

user4143: You can decipher most of them yourself.

A u prefix means unsigned.
The number is the number of bits used. There's 8 bits to the byte.
The _t means it's a typedef.

So a uint8_t is an unsigned 8 bit value, so it takes 1 byte. A uint16_t is an unsigned 16 bit value, so it takes 2 bytes (16/8 = 2)
The only fuzzy one is int. That is "a signed integer value at the native size for the compiler". On an 8-bit system like the ATMega chips that is 16 bits, so 2 bytes. On 32-bit systems, like the ARM based Due, it's 32 bits, so 4 bytes.  Of the three it is the only one that changes.
Personally I rarely use int and always use uint8_t etc., since the variable type is the same no matter what architecture you compile for.  When you use int you can run into problems if you had a program that worked fine on a 32-bit ARM but then doesn't work right on an 8-bit ATMega, since the int can only store a fraction of the range of numbers on the 8-bit system compared to the 32-bit system.

27157: <p>This question is quite clear. What are the differences between an <code>int</code>, an <code>uint8_t</code>, and an <code>uint16_t</code>. I know it has to do with bytes and memory but can someone clarify me a bit?</p>

<p>Things I want to know:</p>

<p>1- How much memory does each take.</p>

<p>2- When to use what.</p>

<p>3- In the end of the day, are they that different?</p>
 4143: <p>You can decipher most of them yourself.</p>

<ul>
<li>A <code>u</code> prefix means <code>unsigned</code>.</li>
<li>The number is the number of bits used. There's 8 bits to the byte.</li>
<li>The <code>_t</code> means it's a <code>typedef</code>.</li>
</ul>

<p>So a <code>uint8_t</code> is an unsigned 8 bit value, so it takes 1 byte. A <code>uint16_t</code> is an unsigned 16 bit value, so it takes 2 bytes (16/8 = 2)</p>

<p>The only fuzzy one is <code>int</code>. That is "a signed integer value at the native size for the compiler". On an 8-bit system like the ATMega chips that is 16 bits, so 2 bytes. On 32-bit systems, like the ARM based Due, it's 32 bits, so 4 bytes.  Of the three it is the only one that changes.</p>

<p>Personally I rarely use <code>int</code> and always use <code>uint8_t</code> etc., since the variable type is the same no matter what architecture you compile for.  When you use <code>int</code> you can run into problems if you had a program that worked fine on a 32-bit ARM but then doesn't work right on an 8-bit ATMega, since the <code>int</code> can only store a fraction of the range of numbers on the 8-bit system compared to the 32-bit system.</p>
