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

JavaScript 进制转换

时间:2018-11-22 02:37:46      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:tostring   script   进制   code   其他   java   转换   har   进制转换   

十进制转其他进制

‘_‘.charCodeAt(0).toString(2) // ‘1011111‘
‘_‘.charCodeAt(0).toString(8) // ‘137‘
‘_‘.charCodeAt(0).toString(10) // ‘95‘
‘_‘.charCodeAt(0).toString(16) // ‘5f’

其他进制转十进制

parseInt(‘_‘.charCodeAt(0).toString(2),  2) // 95
parseInt(‘_‘.charCodeAt(0).toString(8),  8)
parseInt(‘_‘.charCodeAt(0).toString(10),  10)
parseInt(‘_‘.charCodeAt(0).toString(16),  16)

JavaScript 进制转换

标签:tostring   script   进制   code   其他   java   转换   har   进制转换   

原文地址:https://www.cnblogs.com/givingwu/p/9998565.html

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