Two integers divided give an integer. 1 / 2 is 0. Make one side a float, for example 1.0 / 2.
What the message means
The compiler uses the types of the numbers, not the type of the variable that receives the answer.
Fix it in this order
- Write one number with a decimal point, such as 5.0.
- Or cast: (float)a / b.
- Store the result in a float variable.
- Multiply before dividing when you want to stay in integers, as in a * 100 / b.
- Watch for overflow in int, which is 16 bit on an Uno. Use long for big products.
Why it happens
When both numbers are integers, the result is also an integer, and the fraction is thrown away: 1 / 2 is 0. This surprises people when scaling a sensor value.
Make one value a float, for example 1.0 / 2, or cast it: (float)a / b. Do the multiplication first when you need to keep precision with integers.
If you see this, do this
| You see | Do this |
|---|---|
| Result is 0 or 1 only | Integer division. |
| Result wraps to negative | Overflow. Use long. |
Related
map() function, serial monitor shows nothing.
Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.