|
From: | gcc-bugzilla at gcc dot gnu dot org |
Subject: | [Bug classpath/22783] wrong parsing behaviour of NaN, Infinity, -Infinity |
Date: | 16 Oct 2005 01:27:11 -0000 |
Classpath (CVS HEAD 09.25.04) throws a NumberFormatException although [+/-]NaN|Infinity are possible float/double values according to Java documentation. ------- Comment #1 from from-classpath at savannah dot gnu dot org 2004-10-07 14:29 ------- Simple test cases: try { if(Double.POSITIVE_INFINITY == Double.parseDouble("Infinity")) { // OK } else { // WRONG } } catch(NumberFormatException nfe){ // should not happen (but is what its doing now) } aside from the given comparison it can be replaced with: Double.POSITIVE_INFINITY == Double.parseDouble("+Infinity") Double.NEGATIVE_INFINITY == Double.parseDouble("-Infinity") Double.NaN == Double.parseDouble("NaN"); Float.POSITIVE_INFINITY == Float.parseFloat("+Infinity") Float.NEGATIVE_INFINITY == Float.parseFloat("-Infinity") Float.NaN == Float.parseFloat("NaN"); for all examples the string may contain whitespace before and after the 'word'. ------- Comment #2 from from-classpath at savannah dot gnu dot org 2004-10-07 16:05 ------- I've written some Mauve tests that cover these failing cases (plus some other non-failing cases). I'll post them to the mauve-patches mailing list now. ------- Comment #3 from from-classpath at savannah dot gnu dot org 2004-10-07 22:42 ------- I've submitted a quick-fix for this to the classpath-patches list. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22783
[Prev in Thread] | Current Thread | [Next in Thread] |