I need to understand the following:
when I type 4e4
in Google Chrome's console it returns 40000
.
Can anyone help me to understand what is e
in javascript numbers and what is the algorithm working for this?
Thanks in advance
The Math. E property represents Euler's number, the base of natural logarithms, e, which is approximately 2.718. Math.E = e ≈ 2.718.
To get Euler's constant value in JavaScript, use the Math E property. This is a Euler's constant and the base of natural logarithms, approximately 2.718.
Javascript Number() Function object: This parameter holds the objects that will be converted any type of javascript variable to number type. Return Values: Number() function returns the number format for any type of javascript variable. Example 2: Not a number is returned by the compiler.
JavaScript converts any floating-point value with at least six trailing zeros into an annotation by default. 10e1 is 100 and 10e-1 is 1 . You can easily expand this to see that 10eN * 10e-N is always 100 . If you want true scientific notation, as in 1 * 10^2 , you want 1e12 and 1e-12 .
4e4
is a floating-point number representation.
It consists of:
It is also a way of how floating-point numbers are stored on the system. For instance, for single-precision we get: single-precision floating-point number representation
Together, it gives us:
-1^S * M * p^E
where p is the basis of the numerical system
So, in common sense, p can be anything so that 4e4
could be also 4 * 5^4
if p == 5
As we usually work with
decimal values
p is equal to 10
And as was answered before, 4e4 == 4 * 10^4
(as 4 is a decimal value in this case)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With