Use the parseInt Function with a Radix

This is the same as the parseint function, but you can also specify a base for the number which can be between 2 - 36. 2 is binary. Zeros and Ones. I think base 10 is the normal numbering system, but thats just a guess. ;) I'll test it. 3 is an integer.
function using_parseint_radix(maybe_an_int, radix = 2) {
  var result_html = document.getElementById("result");
  var parseint_result = parseInt(maybe_an_int, radix);
  result_html.innerHTML = parseint_result;
  return parseint_result;


<div id='result' class='mb-3 alert alert-primary'>..</div>
<button onclick='using_parseint_radix("0000", "2");' class='btn btn-primary mb-1'>Binary Conversion of 0000</button>
<button onclick='using_parseint_radix("1235", "2");' class='btn btn-primary mb-1'>Binary Conversion of 1235</button>
<button onclick='using_parseint_radix("00001235", "10");' class='btn btn-primary mb-1'>Base 10 Conversion of 00001235</button>



External Link for Use the parseInt Function with a Radix

Other Items in javascript
Page Views

This page has been viewed 246 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
You want to be the best, you MUST put the long yards in! Nothing comes easy in life so stop wishing and start DOING! So many people would rather bitch and moan than help themselves. Dont be one of those negative drainers, start today, make a small change and keep going forwards with this attitude!