您可以对数字使用toString函数,并传递要转换的基数:
(264).toString(16); // 108 hex
(140).toString(16); // 8c hex
Run Code Online (Sandbox Code Playgroud)
而要做相反的事情,你可以使用parseInt函数:
parseInt('108', 16); // 264 dec
parseInt('8c', 16); // 140 dec
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
426 次 |
| 最近记录: |