码迷,mamicode.com
首页 > 编程语言 > 详细

javascript 进制转换(2进制、8进制、10进制、16进制之间的转换)

时间:2017-06-30 17:11:42      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:tostring   color   alert   其他   nbsp   8进制   style   span   rip   

//十进制转其他  
var x=110;  
alert(x);  
alert(x.toString(8));  
alert(x.toString(32));  
alert(x.toString(16));  
//其他转十进制  
var x=‘110‘;  
alert(parseInt(x,2));  
alert(parseInt(x,8));  
alert(parseInt(x,16));  
//其他转其他  
//先用parseInt转成十进制再用toString转到目标进制  
alert(String.fromCharCode(parseInt(141,8)))  
alert(parseInt(‘ff‘,16).toString(2));   

 

javascript 进制转换(2进制、8进制、10进制、16进制之间的转换)

标签:tostring   color   alert   其他   nbsp   8进制   style   span   rip   

原文地址:http://www.cnblogs.com/shcolo/p/7099093.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!