简体   繁体   English

将unsigned long long转换为等效的jni数据类型?

[英]Convert unsigned long long to equivalent jni datatype?

I'm working in Android jni and want to convert the unsigned long long C datatype to equivalent JNI wrapper. 我在Android jni中工作,想将无符号的long long C数据类型转换为等效的JNI包装器。 What should the equivalent jni wrapper be ? 等效的jni包装器应该是什么? Also when I will write the JAVA function call which will call the jni wrapper, what should be the dataype of the JAVA method parameter for this unsigned long long datatype ? 另外,当我编写将调用jni包装器的JAVA函数调用时,此无符号long long数据类型的JAVA方法参数的数据类型应该是什么?

Java doesn't know unsigned. Java不知道未签名。 All Java numerical primitives are signed ( blame Gosling ). 所有Java数字原语都带有符号( 怪罪Gosling )。 If you will really need to transport the unsigned 64bit range over JNI (that is you need [0,2^64] not only [-2^63,2^63-1] ) then there is no equivalent Java wrapper and you will need to decompose the value (like uppper four bytes and lower four bytes). 如果您真的需要通过JNI传输无符号的64位范围(也就是说,不仅需要[0,2^64] [-2^63,2^63-1] ,还需要[0,2^64] [-2^63,2^63-1] ),那么就没有等效的Java包装器,您将需要分解该值(例如向上四个字节,向下四个字节)。 Otherwise you can use simply Java primitive long (JNI jlong) as it is 64bit regardless of the processor architecture. 否则,您可以简单地使用Java原语long(JNI jlong​​),因为它是64位的,而不管处理器的体系结构如何。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM