Not sure if I'm explaining this correctly but as I understand it, numbers in C++/JNI are not the same across all OS's. So I can't just pass them back and forth with the Java code (through JNI) as though they were exactly the same. So my question is: how am I supposed to do this?
I've been told numerous times that i need to be careful of this but never has anyone actually been able to tell me how to safely use/pass numbers with JNI.
Joined: Mar 22, 2005
Floating Point arithmetic is standardized (by IEEE-754) for 32 bit and 64 bit (float and double in Java, respectively), so I'd think that results would be pretty much the same on all platforms. Some platforms may be more accurate internally (say 80 bit), but that will be lost when converting it back to Java.
So I'm not sure where the differences would come from; do you have a specific issue you can point to?
1. On some platforms, ints are 16-bit quantities, and on others they are 32-bit quantities. In the Java platform, of course, an int is always a 32-bit integer.
2. The JNI jlong data type is implemented on the iSeries using a C struct of two integers, instead of a true 8-byte integer. (as one example)
There may be other diff's. As I say, people have told me many times that grabbing integers from C++ and putting them right into java int arrays can lead to mistakes but they can never tell me why or how to ensure the correct passing of numbers.