this question has answer here:
does know how make c equivalent java's float.intbitstofloat method?
https://www.cis.upenn.edu/~bcpierce/courses/629/jdkdocs/api/java.lang.float.html#intbitstofloat(int)
i can't find examples of being ported.
this source has given way this
jniexport jfloat jnicall java_java_lang_float_intbitstofloat(jnienv *env, jclass unused, jint v) { union { int i; float f; } u; u.i = (long)v; return (jfloat)u.f; }
so working around above can .
union int_to_float_bits { int32_t integer_bits; float converted_float_bits; }; float intbitstofloat(int32_t int_value) { union int_to_float_bits bits; bits.integer_bits = int_value; return bits.converted_float_bits; }
Comments
Post a Comment