I am making some approximation functions for exp, log, and sqrt in C for java. I'm a little rusty on how pointers work -- is this grammar correct?
#include <math.h>
#include "QDMath.h"
JNIEXPORT jdouble JNICALL Java_QDMath_exp
(JNIEnv *env, jclass class, jdouble val)
{
jint tmp = (jint) (1512775 * val + 1072632447);
jdouble p = 0.0;
*(1 + (jint * ) &p) = tmp;
return p;
}
JNIEXPORT jdouble JNICALL Java_QDMath_log
(JNIEnv *env, jclass class, jdouble val)
{
jint tmp = (*(1 + (jint *) &val));
jdouble p = ((jdouble) tmp - 1072632447) / 1512775;
return p;
}
JNIEXPORT jdouble JNICALL Java_QDMath_sqrt
(JNIEnv *env, jclass class, jdouble val)
{
jlong tmp = ((*(jlong *) &val) - 1065353216)>>1;
return *(jdouble *) &tmp;
}