How to decleare and initialise a BigDecimal in C++ -
i trying call java method c++ code , using jni, able call java method during call want use bigdecimal inside c++ , can please me use bigdecimal( how declared , initialize) in c++ code.
a bigdecimal
java object native part.
first need create it. therefore need class , method id.
jclass cls = (*env)->findclass(env, "java/math/bigdecimal"); jmethodid = mid = (*env)->getmethodid(env, cls, "<init>", "(d)v");
this construtor of bigdecimal
taking double.
after can create 2 objects.
jobject bd1 = (*env)->newobject(env,cls, mid, 1.222); jobject bd2 = (*env)->newobject(env,cls, mid, 0.0500);
now have 2 bigdecimal
, can add 1 other.
first need add
methodid again.
jmethodid mid2 = (*env)->getmethodid(env, cls, "add", "(ljava/math/bigdecimal;)ljava/math/bigdecimal;");
then can call it.
jobject sum = (*env)->callobjectmethod(env,bd1,mid2,bd2);
now have sum of first 2 bigdecimal
. print out use doublevalue()
function.
Comments
Post a Comment