aspose file tools
The moose likes Other JSE/JEE APIs and the fly likes How ensure numbers are correct for os? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Reply Bookmark "How ensure numbers are correct for os?" Watch "How ensure numbers are correct for os?" New topic
Author

How ensure numbers are correct for os?

Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
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.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35254
    
    7
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?


Android appsImageJ pluginsJava web charts
Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
I believe there are two issues.

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How ensure numbers are correct for os?
 
Similar Threads
how to pass Strng array from java to c Using JNI
can java communicate with windows api?
How to use VB .dll in java
How to pass String array to c++ function
Memory Address