开发者

Bitwise manipulation of signed integers [closed]

开发者 https://www.devze.com 2023-02-28 19:48 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago. 开发者_如何学Go
int p= -6969317
int r=0xff & (p>>16);

what "r" will show and how?


Have a look at the bitwise operations.


If you want to see binary representation of your int, use:

public static String toBitString(final int data){
    final StringBuilder s = new StringBuilder(32);
    for (int i = 31; i >= 0; i--) {
        s.append(data >> i & 1);
    }
    return s.toString();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消