Pet peeve alert: not distinguishing between "IEEE-754 type" and "real number".<p>> System.out.println(5.1+9.2);<p>> We ask to add 5.1 to 9.2. The result should be 14.3, but we get the following instead: 14.299999999999999<p>That's misleading. You put the characters "5.1" in a Java source file, which in Java (like many languages) means "the IEEE-754 64-bit binary floating point value closest to the decimal number 5.1". It's not equal to the real number 5.1. 9.2 and 14.3 can't be represented exactly in binary floating point, either.<p>The number 5.1 + the number 9.2 should be the number 14.3.<p>The Java double 5.1 + the Java double 9.2 should not be the Java double represented by 14.3.<p>The addition isn't really what's hurting you. The representation is. You're confusing the matter by changing type systems in the middle of a sentence.<p>> It is a small difference (only 0.000000000000001), but it is still wrong.<p>The answer is "wrong" in large part because the question was wrong. The error in IEEE-754 "14.3" is only slightly smaller than the error in "5.1+9.2".<p>The sum <i>looks</i> more wrong than the literal "14.3" because Java's Double toString() truncates its output according to some specific rules [1] designed to guess how those 64 bits got there.<p>> CPUs are poor at dealing with floating-point values. Arithmetics are almost always wrong<p>Wouldn't it be more accurate to say they're "wrong" at addition 50% of the time? You picked two numbers whose IEEE-754 representation are both just below their actual value, and whose sum is just above its IEEE-754 representation. Had you added "5.1+5.2" (which happen to be just below and just above their actual values, respectively), the representation errors would have cancelled, and you'd have gotten "10.3" as you expect.<p>[1]: <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#toString(double)" rel="nofollow">https://docs.oracle.com/javase/7/docs/api/java/lang/Double.h...</a>