Data types and overflow
Why int behaves differently on the Uno and the ESP32.
| Type | Arduino Uno | ESP32 |
|---|---|---|
| int | 16-bit: −32 768 … 32 767 | 32-bit: about ±2.1 billion |
| long | 32-bit | 32-bit |
| unsigned long | 0 … 4 294 967 295 | same |
| byte / uint8_t | 0 … 255 | same |
| float / double | 32-bit (double = float!) | float 32-bit, double 64-bit |
On the Uno, int a = 32767; a++; gives −32768. The simulator reproduces this exactly, so code that works here behaves the same on the board.