I was reading a JS book and there was a question asking for output of below:
3e+3
It is giving me 3000
. Can someone explain why?
This is called scientific notation, the xey
means "x
times 10
to the power of y
"
In your case, 3 * Math.pow(10, 3); // 3000
e
declares an exponent. This is known as exponential or scientific notation.
3e+3
is equal to 3e3
(the +
defines a positive number rather than addition), which is equal to 3 * (10^3)
which is equal to 3 * (10*10*10)
which is equal to 3000.
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