DWORD datatype in VC++ nd its conversion in Java
I want to convert a convert a VC++ code into Java, Therefore which Java datatype sholud be used to rep开发者_JAVA技巧lace DWORD datatype in VC++ ?
You can use an int
if you just need a 32-bit value. If you need to perform arithmetic operations or print the value you can use a long
instead.
int i = /* 32-bit value */
long l = i & 0xFFFFFFFFL;
The long can be used as it can have values 0 to 2^32 (and more)
DWORD
is a 4-byte unsigned integer. So it'd be unsigned int
in java. Unfortunately we don't have any unsigned
types in java, so... that'd be just int
. Further reading: http://www.javamex.com/java_equivalents/unsigned.shtml
I know this is an old question, but if anyone else has this problem nowadays and find this question: I did a library to help me to start converting VC++ code to Java.
https://github.com/rfocosi/dotnet-types
Hope it will help someone else.
精彩评论