Binary Decimal Hex Converter

Convert those base numbers

Converting base numbers with JavaScript

This web page uses JavaScript for converting base numbers. JavaScript provides parseInt and toString methods for those purpose.

toString's first param is for converting decimal number to specific base number.

var i = 334;
console.log(i.toString(16)); // display 14e

parseInt's second param is for converting specific base number to decimal.

console.log(parseInt('101001110',2)); // display 334

But parseFloat doesnt provide param for converting base number. You have to write some script If you want to convert float from any base number.

I use those script that is in Stackoverflow.

function parseFloat(string, radix) {
  string = string.split(/\./);
  if (string[0] == '') {
    string[0] = "0";
  }
  if (string.length > 1 && string[1] != '') {
    var fractionLength = string[1].length;
    string[1] = parseInt(string[1], radix);
    string[1] *= Math.pow(radix, -fractionLength);
    return parseInt(string[0], radix) + string[1];
  }
  return parseInt(string[0], radix);
}

numbers - Converting hexadecimal to float in javascript - Stack Overflow

This function provide param for converting base number like parseInt.

console.log(parseFloat('21.666666666666', 16)); // display 33.4