如何在java中使用bit-addresable(assembly)?如何在java中使用位尋址?
例如
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(assembly)?如何在java中使用位尋址?
例如
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
@biziclop,你應該張貼,作爲一個答案。 – 2012-04-06 18:48:47