Using Unsigned int 32 bit in Java? [duplicate]

家住魔仙堡 提交于 2019-12-06 13:57:46

问题


Possible Duplicate:
Converting 32-bit unsigned integer (big endian) to long and back

I want to translate this expression in Java

char tab[100];
tab[10] = '\xc0';

tab[48] = '\x80';

uint32_t w = 0x67452301;

uint32_t x = 0xefcdab89;

uint32_t y = 0x98badcfe;

uint32_t z = 0x10325476;

a = ((b & c) | (~b & d)) + (*(uint32_t*)(tab+0x00)) + a - 0x28955B88;

a = ((a << 0x07) | (a >> 0x19)) + b;

I'have tried this but...

char[] tab = new char[64];

 tab[10] = (char) 0xc0; 
 tab[48] = (char) 0x80; 

but the value is not the right one, is there another way to assign \0x80 in a char[] ? How can i interprete this kind of cast in java ((uint32_t)) ?

Many thanks !


回答1:


Type int is 4 bytes, i.e. 32 bits in java. So the regular 32bits int from C may be translated as regular int in java.

Unsigned int is not supported by java language, so use long that contains 8 bytes to represent unsigned 32 bit variables from C.



来源:https://stackoverflow.com/questions/11759053/using-unsigned-int-32-bit-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!