2 - hundreds decimals not adding up properly? [duplicate]

This question already has an answer here:

Is floating point math broken?

28 answers

New to java, and I know this is ridiculous but it is really bothering me. I have two doubles "63.73" and "80.35", and they add up to a large decimal. These are the only two numbers I can make do this.

Just to simplify and remove any opportunity to cause this.

double a = 63.73;

double b = 78.35;

double total= a + b;

System.out.println(total);

}

}

Always prints 142.07999999999998

Should just print 142.08...

Read More »

By: StackOverFlow - 6 days ago

Related Posts