50 |
static jmethodID isNaNID; |
static jmethodID isNaNID; |
51 |
static jdouble NEGATIVE_INFINITY; |
static jdouble NEGATIVE_INFINITY; |
52 |
static jdouble POSITIVE_INFINITY; |
static jdouble POSITIVE_INFINITY; |
53 |
|
static jdouble NaN; |
54 |
|
|
55 |
/* |
/* |
56 |
* Class: java_lang_Double |
* Class: java_lang_Double |
62 |
{ |
{ |
63 |
jfieldID negInfID; |
jfieldID negInfID; |
64 |
jfieldID posInfID; |
jfieldID posInfID; |
65 |
|
jfieldID nanID; |
66 |
|
|
67 |
isNaNID = (*env)->GetStaticMethodID(env, cls, "isNaN", "(D)Z"); |
isNaNID = (*env)->GetStaticMethodID(env, cls, "isNaN", "(D)Z"); |
68 |
if (isNaNID == NULL) |
if (isNaNID == NULL) |
82 |
DBG("unable to determine field id of POSITIVE_INFINITY\n") |
DBG("unable to determine field id of POSITIVE_INFINITY\n") |
83 |
return; |
return; |
84 |
} |
} |
85 |
|
nanID = (*env)->GetStaticFieldID(env, cls, "NaN", "D"); |
86 |
|
if (posInfID == NULL) |
87 |
|
{ |
88 |
|
DBG("unable to determine field id of NaN\n") |
89 |
|
return; |
90 |
|
} |
91 |
POSITIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, posInfID); |
POSITIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, posInfID); |
92 |
NEGATIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, negInfID); |
NEGATIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, negInfID); |
93 |
|
NaN = (*env)->GetStaticDoubleField(env, cls, nanID); |
94 |
|
|
95 |
#ifdef DEBUG |
#ifdef DEBUG |
96 |
fprintf(stderr, "java.lang.Double.initIDs() POSITIVE_INFINITY = %g\n", POSITIVE_INFINITY); |
fprintf(stderr, "java.lang.Double.initIDs() POSITIVE_INFINITY = %g\n", POSITIVE_INFINITY); |
97 |
fprintf(stderr, "java.lang.Double.initIDs() NEGATIVE_INFINITY = %g\n", NEGATIVE_INFINITY); |
fprintf(stderr, "java.lang.Double.initIDs() NEGATIVE_INFINITY = %g\n", NEGATIVE_INFINITY); |
98 |
|
fprintf(stderr, "java.lang.Double.initIDs() NaN = %g\n", NaN); |
99 |
#endif |
#endif |
100 |
} |
} |
101 |
|
|
262 |
++last_non_ws; |
++last_non_ws; |
263 |
} |
} |
264 |
|
|
265 |
|
/* Check for infinity and NaN */ |
266 |
|
unsigned char *temp = p; |
267 |
|
if(temp[0] == '+' || temp[0] == '-') |
268 |
|
temp++; |
269 |
|
if(strncmp("Infinity", temp, (size_t) 8) == 0) |
270 |
|
{ |
271 |
|
if(p[0] == '-') |
272 |
|
return NEGATIVE_INFINITY; |
273 |
|
return POSITIVE_INFINITY; |
274 |
|
} |
275 |
|
if(strncmp("NaN", temp, (size_t) 3) == 0) |
276 |
|
return NaN; |
277 |
|
|
278 |
/* Skip a trailing `f' or `d'. */ |
/* Skip a trailing `f' or `d'. */ |
279 |
if (last_non_ws > p |
if (last_non_ws > p |
280 |
&& (last_non_ws[-1] == 'f' |
&& (last_non_ws[-1] == 'f' |
289 |
memset (&reent, 0, sizeof reent); |
memset (&reent, 0, sizeof reent); |
290 |
|
|
291 |
#ifdef KISSME_LINUX_USER |
#ifdef KISSME_LINUX_USER |
292 |
|
/* FIXME: The libc strtod may not be reliable. */ |
293 |
val = strtod (p, &endptr); |
val = strtod (p, &endptr); |
294 |
#else |
#else |
295 |
val = _strtod_r (&reent, p, &endptr); |
val = _strtod_r (&reent, p, &endptr); |