This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch Ping: Double.parseDouble cannot handle NaN, Infinity or-Infinity
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: Mark Anderson <mark at panonet dot net>
- Cc: java-patches at gcc dot gnu dot org
- Date: Mon, 14 Mar 2005 12:13:17 -0500
- Subject: Re: Patch Ping: Double.parseDouble cannot handle NaN, Infinity or-Infinity
- References: <200503141355.22728.mark@panonet.net>
Hi Mark,
Thanks for the patch. This approach will be a bit slow because we'd be
allocating 3 strings for every call to parseDouble(). Instead, it would
be better to either:
- do a C strcmp() after the String data has been converted to UTF.
or, perhaps even better:
- put "private static" Java fields containing strings for "NaN",
"Infinity", etc into Double.java, and use those for the string
comparisons. These strings also be reused in the toString()
implementation which currently allocates new strings every time.
Also, since NaN and infinity are probably rare cases, perhaps we can
only check for the special cases in the event that the _strtod_r call fails?
Is there a mauve test for this?
Bryce
Mark Anderson wrote:
http://gcc.gnu.org/ml/java-patches/2005-q1/msg00587.html