最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

3e+3 = 3000 - JavaScript query - Stack Overflow

programmeradmin0浏览0评论

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?

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?

Share Improve this question asked Oct 12, 2013 at 14:50 JS-JS- 9571 gold badge9 silver badges12 bronze badges 0
Add a comment  | 

3 Answers 3

Reset to default 9

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.

It's simple scientific notation. 3e+3 is 3 times 10 to the 3rd power.

发布评论

评论列表(0)

  1. 暂无评论