Float Adding error

when add 0.4 to 0.8 it give 1.20—02


it go for Accuracy not for precision

1 Like

This isn’t a bug, but a result of how floating-point numbers work in Java. Numbers like 0.8 and 0.4 can’t be represented exactly in binary, which causes small rounding errors when performing arithmetic. If precise values are required, consider using integers instead.

2 Likes