Patch Ping: Double.parseDouble cannot handle NaN, Infinity or -Infinity

Bryce McKinlay mckinlay@redhat.com
Mon Mar 14 23:38:00 GMT 2005


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
>  
>



More information about the Java-patches mailing list