简体   繁体   中英

Need some help in java Bit operations?

I have a byte array as: 00SSSMMM

I want to retrieve SSS and MMM values as int values.

Can someone help me in implementing this in java ?

Thanks.

I think you mean

int x = ...
int m = x & 0b111;
int s = (x >> 3) & 0b111;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM