RFA: strtod patch

Per Bothner per@bothner.com
Sun Sep 16 11:32:00 GMT 2001


Mark Mitchell <mark@codesourcery.com> writes:

> Your patch has the effect of making `1.0E' result in an error, I think.

And do it is.  I just verified this by running the following
program under JDK 1.3.1.

public class foo
{
  public static void main(String[] args)
  {
    System.err.println(new Double("1.0e"));
  }
}

> The strtod documentation I have handy does not indicate that is what
> should happen.

C library strtod documentation is irrelevant.  You need to look at
Java documentation, for example:
http://java.sun.com/j2se/1.3/docs/api/java/lang/Double.html#valueOf (java.lang.String)
Note that the strtod.c file defines _Jv_strtod_r,
not a strtod entry point.

> Instead, it indicates that the result should be `1.0',
> and that the pointer pointed to by the second argument to strtod should
> now point at `E'.  Is there a reason that the version in the Java
> library needs to work differently from the usual strtod function?

The main reason we use a hacked-up version of David Gay's strtod is to
get accurate conversion.  But we also need the correct error handling.
Might as well do it in _Jv_strtod_r, rather than create another
syntax-checking wrapper.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/



More information about the Java mailing list