Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

93
Views
Binary Floating point to decimal JavaScript function

To answer the original question that was closed due to an invalid moderation. Binary Floating point to decimal JavaScript fucntion

This function below basically does the math based on the floating point logic.

Does anyone know of a built in function in JavaScript to do this? or a more straight forward way?

function fp32BinToDec(inputFpBinDiv) {
  var inputFpBin = document.getElementById(inputFpBinDiv).value;

  var expBin = inputFpBin.substring(1, 9);
  var mantBin = inputFpBin.substring(9, 33);

  var expDec = (parseInt(expBin, 2) - 127);

  var mantDec = (parseInt(mantBin, 2) / (2 ** 23));

  var dec = ((1 + mantDec) * (2 ** (expDec)));

  document.getElementById('output').innerHTML = dec;
  console.log(dec);
  return dec;
}
<!DOCTYPE html>
<html>

<head>
  <title>Floating point Binary to Decimal</title>
  <script src="site.js"></script>
</head>

<body>
  <button onclick="fp32BinToDec('inputField')">Convert to Decimal</button><br>
  <input id="inputField" value="01000100100110011010000000000000"></input><br>
  <p>Output: </p>
  <div id="output"></div><br>
  <p>Default Floating point binary should result a decimal of 1129</p>
</body>

</html>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!