在Java中使用Unsigned int 32位? [英] Using Unsigned int 32 bit in Java?
问题描述
可能重复:
将32位无符号整数(大尾数)转换为长整型和后退
我要在Java中翻译此表达式
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;
但是值不是正确的,是否有另一种方法来分配\0x80 []?
我如何在java(*(uint32_t *))插值这种类型的转换?
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*)) ?
非常感谢!
推荐答案
输入 int
是4个字节,即java中的32位。因此,从C开始的常规32bits int可以在java中翻译为常规int。
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.
Java语言不支持Unsigned int,因此使用 long
,其中包含8个字节来表示C中的无符号32位变量。
Unsigned int is not supported by java language, so use long
that contains 8 bytes to represent unsigned 32 bit variables from C.
这篇关于在Java中使用Unsigned int 32位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!