Ok , I am using a bunch of different languages but my major problem lies between java , c/c++
Two problems come into play
1) unsigned / signed issues
2) data type size issues
Problem 1
I know that weather the data type is signed or unsigned it doesn't matter since it is going to hold the same value in both data types provided the data types sizes are the same. But for displaying the value problems occur. How can I solve this without always have to create a BigInteger Object in java.
For example
in java
int var = (int)4294967295 ; //still has the same physical value 0xFF 0xFF 0xFF 0xFF it is just displaying this value differently then I want it to display (i.e wanted to print 4294967295 )
Stipulations are that you cann't increase the size of the datatype to make it display correctly.
Since this is legacy code that calls the jni (so I can not manipulate the sizes of the structures I am giving or getting back.
Is their a standard function I can call in java that allows me to display the unsigned value of a variable.
Note this is not only for integers but for shorts , longs , bytes as well?
Don't tell me I have to write my own function that parses thru bits ,..etc and uses the next biggest data structure
(i.e 2^32+...+ 2^3 * bit3 + 2^2*bit2+2*bit1+bit0)
That is my last resort I could do this but I would like to find a function I could call to do this for any variable type.
This problem is just in displaying the value. Note no loss of data occurs when casting from signed to unsigned of the same data type/size I know this at least.
Two problems come into play
1) unsigned / signed issues
2) data type size issues
Problem 1
I know that weather the data type is signed or unsigned it doesn't matter since it is going to hold the same value in both data types provided the data types sizes are the same. But for displaying the value problems occur. How can I solve this without always have to create a BigInteger Object in java.
For example
in java
int var = (int)4294967295 ; //still has the same physical value 0xFF 0xFF 0xFF 0xFF it is just displaying this value differently then I want it to display (i.e wanted to print 4294967295 )
Stipulations are that you cann't increase the size of the datatype to make it display correctly.
Since this is legacy code that calls the jni (so I can not manipulate the sizes of the structures I am giving or getting back.
Is their a standard function I can call in java that allows me to display the unsigned value of a variable.
Note this is not only for integers but for shorts , longs , bytes as well?
Don't tell me I have to write my own function that parses thru bits ,..etc and uses the next biggest data structure
(i.e 2^32+...+ 2^3 * bit3 + 2^2*bit2+2*bit1+bit0)
That is my last resort I could do this but I would like to find a function I could call to do this for any variable type.
This problem is just in displaying the value. Note no loss of data occurs when casting from signed to unsigned of the same data type/size I know this at least.
Last edited: