开发者

How can you represent mathematical constant "e" as a value in JavaScript?

开发者 https://www.devze.com 2022-12-28 02:42 出处:网络
How can you represent mathematical constant \"e\"开发者_开发技巧 as a value in JavaScript?It\'s as easy as

How can you represent mathematical constant "e"开发者_开发技巧 as a value in JavaScript?


It's as easy as

Math.E


Other ways include:

Math.exp(1)

Approximations:

3-sqrt(5/63)

or

(Math.PI^4 + Math.PI^5)^(1/6)

which are good to 7 digits

and

163^(32/163) which is good to 6 digits


Answer was too short, so here is a much much longer version.

Math.E


I believe Math.E is what you want.


You could use the constant:

Math.E


JavaScript provides many mathematical constants that can be accessed from the Math object.

The one you want is Math.E


e is represented by Math.E. But if your intention is to compute e^x, don't write Math.E^x. Use Math.exp(x) instead. It wouldn't be the first time someone has asked for e when they really want exp.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号