如何在java中使用bit-addresable(程序集)?
例如
int a = 13;
int b = 99;
//How can i write 13 & 99 (but & only last bit of 13,99 = 1 & 1)?
//In assembly you can use Acc.0 or anything.x to manipulate bit.
//How to use this feature in java?
如何在java中使用bit-addresable(程序集)?
例如
int a = 13;
int b = 99;
//How can i write 13 & 99 (but & only last bit of 13,99 = 1 & 1)?
//In assembly you can use Acc.0 or anything.x to manipulate bit.
//How to use this feature in java?
int a = 99;
int b = 11;
int q = a & b & 0x1;
此操作没有特殊的语法,直接位操作在 Java 中并不像在汇编中那样重要。
您总是可以使用掩码来实现相同的效果,并且有一个BitSet
类,它可以让您进行各种位操作。
你必须写
(a & b) & 0x01