You have integers in 8, 16, 32 and 64 bits, both signed and unsigned. You have float and double, which can be the same thing on some systems.
There are many names given to those variable types, some standard or ubiquitous, some vague or unique, or change depending on which type of CPU you are working with.
The names aren't important, since they only exist in the source code. All that matters is the underlying size. Names of the same underlying size and signedness are interchangeable at will.
For example:
- uint8_t = unsigned char
- int32_t = long = int on 32 but systems
- uint16_t = unsigned short = int on 8 bit systems
As you can see int
changes depending on the system you are on. So it is best to stick to specifically named types. I always use the [u]int[N]_t
types.
So you have:
- uint8_t
- int8_t
- uint16_t
- int16_t
- uint32_t
- int32_t
- uint64_t
- int64_t
And:
- float
- double (if the compiler supports double on the platform you are compiling for, otherwise it is just float).
Arduino itself provides some more unique variable names that are completely nonstandard, such as byte
for unsigned char
.
In short
(pun intended), stick to variables that specifically define their type if you are worried about how big they all are, and avoid all the rest.
For overloading the compiler will automatically "upscale" the variables to the best fitting available function (known as type promotion) unless functions are flagged as explicit
, so you can have a function with a long
parameter and pass any integer variable up to and including a long
in size. The same with float
/ double
types - if your function takes a double
you can pass it a float
. Useful when you don't know if the target provides a real double
or not - just use double
and it will work regardless with either double
or float
.