2011年10月15日

Javascript 10進位轉換 16進位 8進位 2進位


Math.Int=function(a,b){
 try{
  return a.toString(b).toUpperCase()
 }catch(g){
  return null
 }
}

只要調用Math.int(輸入的數字,幾進位)
就可以囉

範例:

範例:

執行輸出
Math.Int(15)15
Math.Int(15,16)F
Math.Int(15,2)1111
Math.Int(15,8)17

沒有留言:

張貼留言

希望各位在留言時可以選擇身分
Yahoo帳號請選OpenID
網址打yahoo.com
以便回覆時較好辨認及交流
謝謝合作

Powered by s911415 and Blogger