Floating 点 Precision
概念检查 中等
题目
为什么做 `0.1 + 0.2` 不 equal `0.3` in JavaScript?
提示
这个 happens in 所有 languages 那个 use IEEE 754 floating 点.
解释
Computers 存储数字 in binary, and 一些 decimal 分数 (如 0.1) cannot 是 represented 精确地 in binary — 相似到 如何 1/3 cannot 是 represented 精确地 in decimal. 这个 causes tiny rounding 错误: 0.1 + 0.2 = 0.30000000000000004. 这个是 基本 limitation 的 floating-点 arithmetic, 不 bug. 它 affects 所有 IEEE 754 languages.
相关资源
相关课程
- 数字 and Math
学习关于数字 and math 操作.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。