This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: Double.parseDouble cannot handle NaN, Infinity or -Infinity
- From: Mark Anderson <mark at panonet dot net>
- To: java-patches at gcc dot gnu dot org
- Date: Fri, 4 Mar 2005 14:26:09 +0000
- Subject: Patch: Double.parseDouble cannot handle NaN, Infinity or -Infinity
This patch implements handing of NaN, Infinity and -Infinity as agruments to
parseDouble within natDouble.cc.
This is my first experience of CNI so I have no idea if this is the correct
way to handle this. Someone feel free to propse a better solution.
--
Regards,
Mark
2005-03-04 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 Mar 4 13:40:39 2005
*************** java::lang::Double::parseDouble(jstring
*** 181,186 ****
--- 181,198 ----
if (length > 0)
{
+ // check for NaN
+ if (str->equals(JvNewStringLatin1("NaN", strlen("NaN"))))
+ return NaN;
+
+ // check for Infinity
+ if (str->equals(JvNewStringLatin1("Infinity", strlen("Infinity"))))
+ return POSITIVE_INFINITY;
+
+ // check for -Infinity
+ if (str->equals(JvNewStringLatin1("-Infinity", strlen("-Infinity"))))
+ return NEGATIVE_INFINITY;
+
// Note that UTF can expand 3x.
char *data = (char *) __builtin_alloca (3 * length + 1);
jsize blength = _Jv_GetStringUTFRegion (str, start, length, data);