-2

I have custom calculator with js, everything was normal until i found 1.2101997764095421e-12 sometimes X.XXe-13, X.XXe-14

What is this ? How to convert it ?

Update : I have knowledge in excel for this calculator, the result for 1.2101997764095421e-12 should be a 14,78

3 Answers3

0

Those are really long floating point number, and the e-12 represents that there are 12 decimals. To convert it to your desired format you can do this:

var converted = Math.round(number * 100) / 100
overburn
  • 1,194
  • 9
  • 27
0

This is nothing specific to javascript but a common mathematical notation meaning the following:

1e-1 = 0.1
1e-2 = 0.01

x.xxe-13 points to a number having 13 decimals after 0.

mico
  • 12,730
  • 12
  • 59
  • 99
0

This is a representation of Scientific Notation. You can translate the eN to mean x10^N. When a Float number gets to large or small the string representation number will look that way.

1.12345e5 = 1.12345x10^5 = 112345
1.12345e-5 = 1.12345x10^-5 = .0000112345
Gabriel Littman
  • 552
  • 3
  • 13