Why the digits after decimal points increased and who is supplying this additional value after the decimal points?
public class Main {
public static void main(String[] args)
{
double data = 444.324;
float value = 5.1f;
System.out.println(value+data);
}
}
Mathematically speaking the output should have been
449.424
right?
But the output of the following program is
449.4239999046326
Can anyone explain this behavior?
Noone is supplying the digits. You are just seeing rounding errors because floating point numbers cannot be accurately represented in computer memory.
Google floating point errors for more information.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.