Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我以前从未在 Java 中使用过比特,所以问题如下:我有
byte a=254;
如何从这个字节中获取一个位,从 msb 位置开始?
If position == 0 it returns 1 If position == 7 it returns 0
先感谢您
int getBitFromMSB(byte x,int position){ return (x >>> (7 - position)) & 1; }