当前位置: 技术问答>java相关
谁有Java源代码中floatToIntBits,intBitsToFloat的源代码?
来源: 互联网 发布时间:2015-04-12
本文导语: 还有,doubleToLongBits longBitsToDouble? 这些遵循IEEE754规范。 但是,我无法从Jb中找到他们的source code | In java they are all native method So you can't find source code. Because native methods are implemented in platform d...
还有,doubleToLongBits
longBitsToDouble?
这些遵循IEEE754规范。
但是,我无法从Jb中找到他们的source code
longBitsToDouble?
这些遵循IEEE754规范。
但是,我无法从Jb中找到他们的source code
|
In java they are all native method
So you can't find source code.
Because native methods are implemented in platform depedent way,
e.g. *.dll in windows
So you can't find source code.
Because native methods are implemented in platform depedent way,
e.g. *.dll in windows
|
/*
* Find the bit pattern corresponding to a given float, collapsing NaNs
*/
JNIEXPORT jint JNICALL
Java_java_lang_Float_floatToIntBits(JNIEnv *env, jclass unused, jfloat v)
{
union {
int i;
float f;
} u;
if (JVM_IsNaN((float)v)) {
return 0x7fc00000;
}
u.f = (float)v;
return (jint)u.i;
}
这是什么?
* Find the bit pattern corresponding to a given float, collapsing NaNs
*/
JNIEXPORT jint JNICALL
Java_java_lang_Float_floatToIntBits(JNIEnv *env, jclass unused, jfloat v)
{
union {
int i;
float f;
} u;
if (JVM_IsNaN((float)v)) {
return 0x7fc00000;
}
u.f = (float)v;
return (jint)u.i;
}
这是什么?