資源簡介
我自己寫的,感覺 補碼到原碼的轉(zhuǎn)化,在程序中會用到。我寫的是一個串口通訊的項目。我網(wǎng)上找了很久,發(fā)現(xiàn)都沒有人寫過這個代碼,我調(diào)試了半天,寫成功了,大家有需要,就下載,也給我加加積分
代碼片段和文件信息
import?javax.swing.JOptionPane;
public?class?TestMath1?{
/**
?????*?補碼到原碼的轉(zhuǎn)化函數(shù)
?????*?**/
public?static?void?main(String[]?args)?{
//?TODO?Auto-generated?method?stub
String?str=JOptionPane.showInputDialog(““?“請輸入一個十六位數(shù)!“);
int?result=Integer.parseInt(str?16);
if(result>=128){
//取出每一位的值
int?wei[]=new?int[7];
for(int?i=0;i<7;i++){
int?x?=?0x1?&?(Integer.parseInt(str?1
評論
共有 條評論