The method of using JavaScript to convert into binary
Today in the Web site to use the conversion, so on-line search, found that you can directly use JavaScript's ToString () method and the parseint () method for the conversion between decimal and other binary, here to their usage of the collation.
ToString () Method: Converts decimal number to other binary number
parseint () Method: Convert other numbers to decimal
<script language= "javascript" type= "Text/javascript" >
var htmer=function (s) {document.write (' <br/> ' +s)}; Output results
Convert decimal numbers to other binary numbers
var x=123;
Htmer (x.tostring (2)); Convert to 2 binary
Htmer (x.tostring (8)); Convert to 8 binary
Htmer (X.tostring (16)); Convert to 16 binary
Convert other binary numbers to decimal numbers
var x= ' 10 ';
Htmer (parseint (x,2)); Converts 2 binary 10 to decimal
Htmer (parseint (x,8)); Converts 8 binary 10 to Decimal
Htmer (parseint (x,16)); Converts 16 binary 10 to decimal
</script>
Tip: If you want to convert between other binary numbers, you can convert them in decimal. For example, if you want to convert the 2 binary number to 8, you can convert the 2 binary number to decimal number, then convert the decimal number to the 8 binary number.
This article link address: http://www.htmer.com/article/618.htm
JS in-system conversion