java int轉(zhuǎn)二進(jìn)制 將十進(jìn)制50,163,1819,2020轉(zhuǎn)換成二進(jìn)制數(shù)計(jì)算過程?
將十進(jìn)制50,163,1819,2020轉(zhuǎn)換成二進(jìn)制數(shù)計(jì)算過程?50=32*1 16*1 8*0 4*0 2*1 1*0,二進(jìn)制數(shù)為11 0010。163=128*164*0 32*1 16*0 8*
將十進(jìn)制50,163,1819,2020轉(zhuǎn)換成二進(jìn)制數(shù)計(jì)算過程?
50=32*1 16*1 8*0 4*0 2*1 1*0,二進(jìn)制數(shù)為11 0010。
163=128*164*0 32*1 16*0 8*0 4*0 2*1 1*1,二進(jìn)制數(shù)為1010 0011。
1819=1024*1 512*1 256*1 128*0 64*0 32*0 16*1 8*1 4*0 2*1 1*1,轉(zhuǎn)換二進(jìn)制數(shù)為111 0001 1011。
2020=1024*1 512*1 256*1 128*1 64*1 32*1 16*0 8*0 4*1 2*0 1*0,轉(zhuǎn)換后的二進(jìn)制數(shù)為111 1110 0100。
Java怎么用整數(shù)轉(zhuǎn)換二進(jìn)制跟16進(jìn)制,方法簡單點(diǎn),謝謝?
查看整數(shù)API:靜態(tài)字符串tobinarystring(int i)以二進(jìn)制(基數(shù)2)無符號(hào)整數(shù)的形式返回整數(shù)參數(shù)的字符串表示形式。Static string tohexstring(int i)將整數(shù)參數(shù)的字符串表示形式返回為十六進(jìn)制無符號(hào)整數(shù)。靜態(tài)字符串tooctalstring(inti)以八進(jìn)制(基數(shù)8)無符號(hào)整數(shù)的形式返回整數(shù)參數(shù)的字符串表示形式。
Java中如何把圖片轉(zhuǎn)換成二進(jìn)制流?
使用Java的IO流讀取二進(jìn)制圖像
示例是:以二進(jìn)制流的形式讀取圖像并將其寫入其他圖像
static void testcopyimage(){T/tfile source=new file(“E:share wallpaper布利斯.jpg“” File desk=新文件(“d:images”) if(!desk.exists存在()){ desk.mkdir文件() } try{ FileInputStream inputStream=new FileInputStream(源) FileOutputStream outputStream=new FileOutputStream(新文件(”d:/images/布利斯.jpg“”) 顏色=inputStream.read文件() 時(shí)間(ch!=-1){ outputStream.write文件(信道) ch=inputStream.read文件() } inputStream.關(guān)閉() outputStream.close文件() 系統(tǒng)輸出打?。▓D片復(fù)制成功!“” }catch(FileNotFoundException e){ 系統(tǒng)輸出打印(”文件不存在:”e.getmessage())T/T}catch(IOException e){T/T} 系統(tǒng)輸出打?。ā拔募x取錯(cuò)誤:”e.getmessage())T/T}T/T}