Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

95
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda