亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問有誰能給我解釋一下那個printComplement方法不?

請問有誰能給我解釋一下那個printComplement方法不?

123Zhou123 2016-03-17 14:36:03
public class TransCode1{? ? private int data;? ? public void TranCode(int data){? ? ? ? this.data=data;? ? }? ? public void printComplement(){? ? ? ? for(int i=0;i<32;i++){? ? ? ? ? ? int t=(data &(0x80000000>>>1))>>>(31-i);? ? ? ? ? ? System.out.print(t);? ? ? ? }? ? }? ? public static void main(String[] args){? ? ? ? TransCode transCode=new TransCode();? ? ? ? transCode.printComplement();? ? }}
查看完整描述

1 回答

已采納
?
qq___524

TA貢獻171條經驗 獲得超74個贊

data &(0x80000000>>>1)是將data與0100 0000 0000 0000 0000 0000 0000 0000(二進制)做與運算,如果data的第31位是0,結果就是0,如果是1,結果就是0100 0000 0000 0000 0000 0000 0000 0000,然后在將結果右移(31-i)位,群前面用0填充

查看完整回答
1 反對 回復 2016-03-17
  • 1 回答
  • 0 關注
  • 1331 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號