Why are the values of String.valueOf(5.6d + 5.8d)
and String.format("%f", 5.6d + 5.8d)
diffrent?
String.valueOf(5.6d + 5.8d)
will print "11.399999999999999".
String.format("%f", 5.6d + 5.8d)
will print "11.400000".
Why is it so?
Edit: The question differs to Is floating point math broken? , because String.format()
round up (see answers)