How to create a mathematical number 1e6 in JavaScript?

How to create number 1e6 with javascript?

var veryLargeNumber = //1e6 
+6
source share
5 answers

Here are some ways:

 var veryLargeNumber = 1e6; var veryLargeNumber = 1.0e+06; var veryLargeNumber = 1000000; var veryLargeNumber = 0xf4240; var veryLargeNumber = 03641100; var veryLargeNumber = Math.pow(10, 6); 
+16
source

It is written as you wrote it: var notVeryLargeNumber = 1e6 .

+2
source

As you wrote above:

 var veryLargeNumber = 1e6;//Equals to 1*10^6 
+1
source

This works great for me.

 var veryLargeNumber = 1e6; console.log( veryLargeNumber ); 

outputs:

1,000,000

For more information on truly β€œlarge” numbers in JavaScript, look at this question:

What is JavaScript Max Int? What is the highest value An integer can go without loss of precision?

+1
source

For the curious, I went to study a little safari ...

Although E denotes an exponent, the designation is usually called the (scientific) designation E or the (scientific) designation

...

Since indexes with an index such as 10 ^ 7 may not always be conveniently displayed, the letter E or e is often used to represent "ten times magnified to a power" (which will be written as "Γ— 10n"), followed by exponent value; in other words, for any two real numbers m and n, using "mEn" will indicate the value m Γ— 10n.

https://en.wikipedia.org/wiki/Scientific_notation#E_notation


Use exponential notation if the number starts with "0." and then more than five zeros. Example:

 > 0.0000003 3e-7 

http://www.2ality.com/2012/03/displaying-numbers.html


Also: How to convert a String containing Scientific Notation to fix Javascript format

 Number("4.874915326E7") //returns 48749153.26 
0
source

Source: https://habr.com/ru/post/919260/


All Articles