whats int16_t

I know this is a silly question but cant find the answer what is int16_t or just int16

1 Like

Create an integer : int n;
That is a 16-bit integer on most Arduino boards.

However, on the Arduino Due, that is a 32-bit integer.

Suppose a sensor uses a 16-bit integer or you want to create an integer that is always 16-bit. That is when the "int16_t" is used. It is always 16 bits on all Arduino boards.
I think that is part of the gcc compiler : avr-libc: <stdint.h>: Standard Integer Types

And as a side case, if you need a minimum of 16 bits, but want to use it in a critical (fast) section of code, the definitions int_fast16_t can be used. On the 8 bit AVR you will get an integer of 16 bits, whereas the due uses 32 bit registers, so it can produce faster code with 32 bit ints, and the int_fast16_t will be sized to reflect this.