Home > Web Front-end > JS Tutorial > JavaScript simple hexadecimal conversion implementation method

JavaScript simple hexadecimal conversion implementation method

高洛峰
Release: 2016-12-05 13:32:58
Original
1843 people have browsed it

The example in this article describes the implementation method of simple hexadecimal conversion in JavaScript. Share it with everyone for your reference, the details are as follows:

Base conversion under JavaScript is very convenient. The system has provided built-in methods to provide conversion between 2 and 36 bases. The representations directly provided include octal, decimal, and hexadecimal.

var w=function(s){document.write(&#39;<br>&#39;+s)};
//十进制转其他
var x=110;
w(x);
w(x.toString(8));
w(x.toString(32));
w(x.toString(16));
//其他转十进制
var x=&#39;110&#39;;
w(parseInt(x,2));
w(parseInt(x,8));
w(parseInt(x,16));
//其他转其他
//先用parseInt转成十进制再用toString转到目标进制
Copy after login


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template