# Retain precision with Doubles in java?

Possible Duplicate:
Why do I see a double variable initialized to some value like 21.4 as 21.399999618530273?

public class doublePrecision {
public static void main(String[] args) {

``````    double total = 0;
total += 5.6;
total += 5.8;
System.out.println(total);
}
``````

}
Which returns

11.399999999999
Okay clarifying the question a bit: how would I get this to just print (or be able to use it as) 11.4?

``````When you type 33.33333333333333, the value you get is actually the closest representable double-precision value, which is exactly:

33.3333333333333285963817615993320941925048828125

Dividing that by 100 gives:

0.333333333333333285963817615993320941925048828125

which also isn't representable as a double-precision number, so again it is rounded to the nearest representable value, which is exactly:

0.3333333333333332593184650249895639717578887939453125

When you print this value out, it gets rounded yet again to 17 decimal digits, giving:

0.33333333333333326``````