Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting jdouble to double of type c

How can i convert jdouble of java type variable to double variable of type c ?

like image 278
program-o-steve Avatar asked May 09 '12 12:05

program-o-steve


1 Answers

You don't have to, it's just a typedef like so:

typedef double jdouble;

So no conversion is needed, once you have a jdouble you can treat it just as a double.

See for instance this code example from Standford:

JNIEXPORT jdouble JNICALL Java_Summer_sum__DD
(JNIEnv *env, jobject jobj, jdouble j1, jdouble j2) {
    return j1 + j2;
}

The addition is done directly with the jdouble values, trusting the compiler to figure out how to generate the required code.

like image 145
unwind Avatar answered Nov 06 '22 13:11

unwind