gpt4 book ai didi

数字文字混淆中的 JavaScript 指数

转载 作者:行者123 更新时间:2023-12-02 23:27:44 27 4
gpt4 key购买 nike

也许是时候喝一杯咖啡了,但我看到了一个我没想到会看到的奇怪问题。

我正在阅读 JavaScript The Good Parts,在语法部分我看到以下内容:

If a number literal has an exponent part, then the value of the literal is computed by multiplying the part before the e by 10 raised to the power of the part after the e. So 100 and 1e2 are the same number.

From pg. 8 of JavaScript: The Good Parts by Douglas Crockford. Copyright 2008 Yahoo! Inc., 978-0-596-51774-8.

我认为 2e2 应该等于 400 是错误的吗?

按照书上的说法,这个值不应该是(2*10)^2吗?

在我的控制台中,它显示 2e2 == 200.. 我的数学、阅读理解或其他方面是否有问题?我需要回到基础代数吗?

提前致谢。

最佳答案

2e2 被解释为 2*(10^2) 而不是 (2*10)^2。前者的计算结果为 2 * 100,等于 200。后者的计算结果为 20 ^ 2,这就是您得到 400 的原因。

关于数字文字混淆中的 JavaScript 指数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56657074/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com