Using toString() with radix

In this example below you will see how to do a Using toString() with radix with some HTML / CSS and Javascript

Useful way of converting numbers from decimal to other bases using toString() in javascript

Thumbnail
This awesome code was written by 2toria, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 2toria ©
  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Using toString() with radix</title>
  
  
  
  
  
</head>

<body>

  
  
  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/2toria/using-tostring-with-radix-uqaBb */
var num = 123345;
alert(num.toString(2)); //Binary
alert(num.toString(8)); //Octal
alert(num.toString(16)); //Hexadecimal

Comments