Decimal places in JavaScript

1

What kind of variable can I use to generate the maximum number of decimal places in JavaScript?

Eg: 1.9871975109731928479128471023789182479182471209381290481284

If possible, logical =)

    
asked by anonymous 11.03.2018 / 20:32

2 answers

1

JavaScript has only one numeric type, so it's the one it should use. Of course, it has a maximum and it's the maximum you can use.

It's good to know that JS uses a numeric type based on binary floating point and this means that there will be no numerical accuracy if you need this does not, but by the above does not seem to be the case. The maximum is Number.MAX_VALUE .

console.log(Number.MAX_VALUE);

If this does not resolve, you will have to make or take a library that creates a type that meets your need.

    
11.03.2018 / 20:52
0

The numbers in JavaScript are always of type Number , and always are 64-bit floating point in the IEEE 754 standard:

  • Mantissa / Fraction: 52 bits;
  • Exponent: 11 bits;
  • Signal: 1 bit;
  

The maximum value that can be reached is approximately 3.4028235 × 10e38

    
13.03.2018 / 14:31