Example of Javascript hexadecimal conversion
This article describes how to convert Javascript code. Share it with you for your reference. The details are as follows:
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 |
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> hexadecimal conversion </title>
<Script type = "text/javascript">
Var x = 6;
Var num = x. toString (2 );
// Convert the integer to binary. Note that 2 in the toString method indicates "binary"
// Alert ("num =" + num );
Var z = "110 ";
Var num2 = parseInt (z, 2 );
// Note that the second parameter of the parseInt method indicates that z is a binary number,
// Convert the value to an integer of 6.
Alert ("num2 =" + num2 );
</Script>
</Head>
<Body>
</Body>
</Html>
|
I hope this article will help you design javascript programs.