Using Unsigned Int 32 Bit in Java? [Duplicate]

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 !

6

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.

4
Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest