Hello,
You've observed a known change in behavior:
JDK-7131459 [Fmt-De] DecimalFormat produces wrong format() results
when close to a tie
https://bugs.openjdk.java.net/browse/JDK-7131459
The new result is actually numerically correct since the text string
"85.55" does not get converted to a double value actually equal to 85.55
it is converted to a value slightly less than 85.55.
HTH,
-Joe
On 02/24/2014 10:09 AM, David P. Caldwell wrote:
Here's a bug report for b129. Mac OS X 10.8.5, although I doubt this is
platform-dependent.
DecimalFormatTest.java
public class DecimalFormatTest {
public static void main(String[] args) {
System.out.println("java.version: " +
System.getProperty("java.version"));
System.out.println("85.55 rounded to one digit: " + new
java.text.DecimalFormat("##.#").format(85.55));
}
}
DecimalFormatTest.sh
#!/bin/bash
javac -source 1.6 -target 1.6 $(dirname $0)/DecimalFormatTest.java
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java
DecimalFormatTest
/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/java
DecimalFormatTest
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/java
DecimalFormatTest
/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/java
DecimalFormatTest
/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/java -version
uname -a
Output:
$ ./DecimalFormatTest.sh
warning: [options] bootstrap class path not set in conjunction with -source 1.6
1 warning
java.version: 1.6.0_65
85.55 rounded to one digit: 85.6
java.version: 1.7.0_25
85.55 rounded to one digit: 85.6
java.version: 1.7.0_45
85.55 rounded to one digit: 85.6
java.version: 1.8.0
85.55 rounded to one digit: 85.5
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b129)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b69, mixed mode)
Darwin mabosdcaldwell-m1.corp.local 12.5.0 Darwin Kernel Version 12.5.0: Sun
Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64
The DecimalFormat specification says it should use HALF_EVEN as the rounding
mode. The getRoundingMode() method for the DecimalFormat (examined in debugger)
does in fact return HALF_EVEN, but the output is incorrect.
-- David P. Caldwell
http://www.davidpcaldwell.com/
On Feb 4, 2014, at 9:31 AM, Mathias Axelsson <mathias.axels...@oracle.com>
wrote:
Hi,
I'd like to give you an update on the below. We've promoted b128 and this
is the first release candidate build of JDK 8. b128 is available on
java.net [1] so you can download it and try it out.
I'll continue to monitor incoming bugs. If a showstopper bug shows up that
is deemed critical for the JDK 8 release then we'll have to create a new
build to include it.
Kind regards,
Mathias Axelsson, Oracle JDK Release Manager
[1] https://jdk8.java.net/download.html
On 31 jan 2014, at 12:55, Mathias Axelsson <mathias.axels...@oracle.com> wrote:
Hi,
It's been a while since my last update so I wanted to give you an update on
where we are.
Focus has been on getting the final RI (Reference Implementation) build for
the Java SE 8 specification completed and ready. The current RI build is
b126 [1] and unless any TCK blockers shows up, this build will be the RI
for Java SE 8.
With the RI build in place focus has now shifted to get the remaining
showstopper fixes for JDK 8 into the master. We had a number of fixes lined
up and got them integrated earlier this week so that we could do a new
promoted build (b127). This build will be posted on java.net [2] shortly.
b127 is not a release candidate build as there are still a few critical
issues that must be fixed and integrated. I'm following up on the bugs on a
daily basis and hope we can cut the first release candidate of JDK 8
shortly.
I will send out an update once we have a release candidate build of JDK 8.
Kind regards,
Mathias Axelsson, Oracle JDK 8 Release Manager
[1] https://jdk8.java.net/java-se-8-ri/
[2] https://jdk8.java.net/download.html