Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

170
Visualizações
Number with too many decimal places ends up in scientific notation

I am getting a price from a 3rd party API which is returned in scientific notation. When I actually check this price on their site, its shown as 1.20 but the api returns 1.2052626e

I want to perform a multiplication with that price field and format it to a currency string but it always returns as 0.00 cause of that scientific notation. Is there any way I can turn this 1.2052626e into a 1.20 or to a fixed amount of decimals for all scientific notations returned by that api?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use parseFloat to convert it to a decimal number and then use the toFixed method on it.

const res = "1.2052626e";
console.log(parseFloat("1.2052626e").toFixed(2)); // as string

console.log(+parseFloat("1.2052626e").toFixed(2)); // as number

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda