27 |
|
|
28 |
#include <config.h> |
#include <config.h> |
29 |
#include <stdlib.h> |
#include <stdlib.h> |
30 |
|
#include <stdio.h> |
31 |
#include <string.h> |
#include <string.h> |
32 |
|
|
33 |
#include "mprec.h" |
#include "mprec.h" |
36 |
|
|
37 |
#include "java_lang_Double.h" |
#include "java_lang_Double.h" |
38 |
|
|
39 |
|
static jmethodID isNaNID; |
40 |
|
static jdouble NEGATIVE_INFINITY; |
41 |
|
static jdouble POSITIVE_INFINITY; |
42 |
|
|
43 |
/* |
/* |
44 |
* Class: java_lang_Double |
* Class: java_lang_Double |
45 |
* Method: initIDs |
* Method: initIDs |
46 |
* Signature: () |
* Signature: () |
47 |
*/ |
*/ |
|
jmethodID isNaNID; |
|
|
jdouble NEGATIVE_INFINITY; |
|
|
jdouble POSITIVE_INFINITY; |
|
|
|
|
48 |
JNIEXPORT void JNICALL Java_java_lang_Double_initIDs |
JNIEXPORT void JNICALL Java_java_lang_Double_initIDs |
49 |
(JNIEnv *env, jclass cls) |
(JNIEnv *env, jclass cls) |
50 |
{ |
{ |
71 |
} |
} |
72 |
POSITIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, posInfID); |
POSITIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, posInfID); |
73 |
NEGATIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, negInfID); |
NEGATIVE_INFINITY = (*env)->GetStaticDoubleField(env, cls, negInfID); |
74 |
|
|
75 |
|
#ifdef DEBUG |
76 |
|
fprintf(stderr, "java.lang.Double.initIDs() POSITIVE_INFINITY = %g\n", POSITIVE_INFINITY); |
77 |
|
fprintf(stderr, "java.lang.Double.initIDs() NEGATIVE_INFINITY = %g\n", NEGATIVE_INFINITY); |
78 |
|
#endif |
79 |
} |
} |
80 |
|
|
81 |
/* |
/* |
138 |
char *s, *d; |
char *s, *d; |
139 |
int i; |
int i; |
140 |
|
|
141 |
|
#ifdef DEBUG |
142 |
|
fprintf (stderr, "java.lang.Double.toString (%g)\n", value); |
143 |
|
#endif |
144 |
|
|
145 |
if ((*env)->CallStaticBooleanMethod(env, cls, isNaNID, value)) |
if ((*env)->CallStaticBooleanMethod(env, cls, isNaNID, value)) |
146 |
return (*env)->NewStringUTF(env, "NaN"); |
return (*env)->NewStringUTF(env, "NaN"); |
147 |
|
|
148 |
if ( ((jlong) value) == ((jlong)POSITIVE_INFINITY)) |
if (value == POSITIVE_INFINITY) |
149 |
return (*env)->NewStringUTF(env, "Infinity"); |
return (*env)->NewStringUTF(env, "Infinity"); |
150 |
|
|
151 |
if (value == NEGATIVE_INFINITY) |
if (value == NEGATIVE_INFINITY) |