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: Mark Anderson <mark at panonet dot net>
- To: Bryce McKinlay <mckinlay at redhat dot com>, tromey at redhat dot com
- Cc: Andrew Haley <aph at redhat dot com>, java-patches at gcc dot gnu dot org
- Date: Fri, 1 Apr 2005 13:53:30 +0000
- Subject: Re: Patch Ping: Double.parseDouble cannot handle NaN, Infinity or-Infinity
- References: <200503171459.54699.mark@panonet.net> <m31x9x55d2.fsf@localhost.localdomain> <424B00E4.9080805@redhat.com>
On Wednesday 30 March 2005 20:41, Bryce McKinlay wrote:
> Tom Tromey wrote:
> >Mark> So do we have a final decision so I can produce a final patch
> >Mark> for this bug?
> >
> >You're probably not going to get a real final decision. Write it one
> >way, I will approve it. Write it the other way, Bryce will approve
> >it. It will all come out in the wash when we do the Big Classpath
> >Merge anyway.
>
> Yeah. I think my solution is somewhat more elegant, but avoiding
> divergances from Classpath is the overriding concern - ie we'd need to
> make the corresponding change in Classpath's JNI implementation of the
> native parts of Double. That should be a fairly minor change, but I'm ok
> with Tom's approach too if you don't want to do that.
>
> Bryce
OK, here is the final patch. I have went Tom's way to avoid having to make any other changes.
Will this be committed to 4.0 as well?
--
Regards,
Mark
2005-04-01 Mark Anderson <mark@panonet.net>
* java/lang/natDouble.cc (parseDouble): Handle NaN, Infinity and -Infinity as
parameters
*** java/lang/natDouble.cc.orig Fri Mar 4 12:35:22 2005
--- java/lang/natDouble.cc Fri Apr 1 14:26:32 2005
*************** java::lang::Double::parseDouble(jstring
*** 193,198 ****
--- 193,208 ----
double val = _strtod_r (&reent, data, &endptr);
if (endptr == data + blength)
return val;
+ else
+ {
+ // check for NaN, Infinity & -Infinity
+ if (str->equals(JvNewStringLatin1("NaN", strlen("NaN"))))
+ return NaN;
+ else if (str->equals(JvNewStringLatin1("Infinity", strlen("Infinity"))))
+ return POSITIVE_INFINITY;
+ else if (str->equals(JvNewStringLatin1("-Infinity", strlen("-Infinity"))))
+ return NEGATIVE_INFINITY;
+ }
}
throw new NumberFormatException(str);
}