According to the JavaDoc, DecimalFormat uses "half even rounding", which is described as...
Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor. Behaves as for ROUND_HALF_UP if the digit to the left of the discarded fraction is odd; behaves as for ROUND_HALF_DOWN if it's even. Note that this is the rounding mode that minimizes cumulative error when applied repeatedly over a sequence of calculations.
When you click on RoundingMode.HALF_EVEN, you are taken to the definition Henry quoted from java.math.RoundingMode.
Using the setRoundingMode method in DecimalFormat will change this as desired...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: Oct 12, 2005
I was looking at the API for Java 1.3 and that is why I couldn't find the quote. The API for DecimalFormat in Java 1.3 says nothing about rounding.
I have one computer with Java 1.3 and one with Java 1.5 and my program so far runs on both computers.
Java 1.5 has a note about rounding, but it refers to a field in the class BigDecimal. I think Java 1.3 has BigDecimal, too, so I will look carefully at the API for BigDecimal and see if I can use it to do what I want, or maybe link it somehow to NumberFormat or DecimalFormat.