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

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
Copyright 2toria ©
  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

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



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



/*Downloaded from */
var num = 123345;
alert(num.toString(2)); //Binary
alert(num.toString(8)); //Octal
alert(num.toString(16)); //Hexadecimal