java jint,JNI:将unsigned int转换为jint
How do I convert an unsigned int to jint? Do I have to convert it at all, or can I just return it without any special treatment? This is basically my code right now, but I can't test it, as I haven't setup JNI locally.
JNIEXPORT jint JNICALL
Java_test_test(JNIEnv* env, jobject obj, jlong ptr)
{
MyObject* m = (MyObject*) ptr;
unsigned int i = m->get();
return i;
}
解決方案
In the general case, jint is equivalent to int, and so can hold about half the values of unsigned int. Conversion will work silently, but if a jint value is negative or if an unsigned int value is larger than the maximum value a jint can hold, the result will not be what you are expecting.
總結
以上是生活随笔為你收集整理的java jint,JNI:将unsigned int转换为jint的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 感音神经性耳聋能治好吗?
- 下一篇: 用眼过度眼睛疼怎么办?