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

127
Vistas
Calculating a sum in Javascript that is more than 16 digits (without rounding)?

I'm a noob coder and I'm trying to make a small app that generates random math problems with x amount of digits. It works fine until I try something like multiplying two 9 digit numbers.

Here is the block of code that calculates the two randomly generated numbers:

let sum1 = 0
let sum2 = 0
function answer() {
let theAnswer = 0
scoreOnce = 1
if (operatorEl.textContent === "+") {
    theAnswer = sum1 + sum2
    fullsum.textContent = theAnswer
} else if (operatorEl.textContent === "-") {
    theAnswer = sum1 - sum2
    fullsum.textContent = theAnswer
} else if (operatorEl.textContent === "*") {
    theAnswer = sum1 * sum2
    fullsum.textContent = theAnswer
} else if (operatorEl.textContent === "÷") {
    theAnswer = sum1 / sum2
    fullsum.textContent = theAnswer
}
}

And this is how I generate the numbers (9 digit numbers in this case):

function generate9() {
sum1 = Math.floor(Math.random() * (999999999 - 100000000 +1)) + 100000000
    topNum.textContent = sum1
    sum2 = Math.floor(Math.random() * (sum1 - 100000000 +1)) + 100000000
    botNum.textContent = sum2
    fullsum.textContent = "____"
    fullsum.style.color = "#FFFFFF"
    inputEl.value = ''
    scoreOnce = 0
}
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