提交 a09296fb 编写于 作者: L liuhui

fix: digits typo

Signed-off-by: Nliuhui <liuhui@ohos.com.cn>
上级 80db5b26
......@@ -643,7 +643,7 @@ The effective solutions are as follows:
1. Use integers as much as possible because integers do not need to be rounded.
2. The native JavaScript method `Number.prototype.toFixed(digits)`,`digist` is used to indicate the number of digits after the decimal point. The exponential method is not used. If necessary, the number is rounded off. This method is used to reduce the precision of the calculation result before determining the floating-point number calculation result. The sample code is as follows:
2. The native JavaScript method `Number.prototype.toFixed(digits)`,`digits` is used to indicate the number of digits after the decimal point. The exponential method is not used. If necessary, the number is rounded off. This method is used to reduce the precision of the calculation result before determining the floating-point number calculation result. The sample code is as follows:
```javascript
parseFloat(0.1 + 0.2).toFixed(1); //0.3
......
......@@ -643,7 +643,7 @@ console.log(sum2); // 输出:0.6。所以对于二进制浮点数,(a + b) +
1. 尽可能的采用整数值运算,因为整数在表示是不需要舍入;
2. 使用JavaScript的原生方法`Number.prototype.toFixed(digits)`,`digist`参数表示小数点后数字的个数,不使用指数法,在必要时会进行四舍五入。使用该方法,在判断浮点数运算结果前对计算结果进行精度缩小。示例代码如下所示:
2. 使用JavaScript的原生方法`Number.prototype.toFixed(digits)`,`digits`参数表示小数点后数字的个数,不使用指数法,在必要时会进行四舍五入。使用该方法,在判断浮点数运算结果前对计算结果进行精度缩小。示例代码如下所示:
```javascript
parseFloat(0.1 + 0.2).toFixed(1); //0.3
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部