Request for sponsor: 4421494 infinite loop while parsing double literal
Joe Darcy
Joe.Darcy at Sun.COM
Tue Nov 10 03:50:50 UTC 2009
Dmitry Nadezhin wrote:
> http://bugs.sun.com/view_bug.do?bug_id=4421494
> https://bugs.openjdk.java.net/show_bug.cgi?id=100119
>
> Summary: This old bug report says that Double.parseDouble(s) hangs for
> decimal strings
> in range (Double.MIN_NORMAL-0.5*Double.MIN_VALUE,Double.MIN), and returns
> incorrect result for decimal string
> Double.MIN_NORMAL-0.5*Double.MIN_VALUE.
>
> This is because current code in FloatingDecimal.doubleValue() incorrectly
> defines the condition when nextDown(dValue) - dValue ==
> -0.5*ulp(dValue). The
> current code considers that these are all numbers 2^n which are
> represented as
> normal doubles, and nexDown(dValue) - dValue == -1.0*ulp(dValue) for
> other
> doubles (subnormal or not 2-powers).
> However, this is not correct for dValue == Double.MIN_VALUE, because
> nextDown(Double.MIN_NORMAL) - Double.MIN_NORMAL ==
> -1.0*ulp(Double.MIN_NORMAL).
>
> The suggested change
> - if ( (bigIntNBits == 1) && (bigIntExp > -expBias) ){
> + if ( (bigIntNBits == 1) && (bigIntExp >
> -expBias+1) ){
> redefines the condition so that dValue == Double.MIN_NORMAL doesn't
> satisfy it.
>
> -Dima
Hello.
Thank you for the proposed fix; that certainly sounds like a plausible
cause of the problem.
I'm a bit swamped now, but I'll try to look at verifying the fix and
sponsoring getting it back into the JDK within the next few weeks.
-Joe
More information about the core-libs-dev
mailing list