From a09296fbd4e8a612ac31d613b5d8fd399aadb875 Mon Sep 17 00:00:00 2001 From: liuhui Date: Thu, 26 May 2022 16:00:06 +0800 Subject: [PATCH] fix: digits typo Signed-off-by: liuhui --- en/contribute/OpenHarmony-JavaScript-coding-style-guide.md | 2 +- zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md b/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md index f540122b83..ff9bc6ddca 100755 --- a/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md +++ b/en/contribute/OpenHarmony-JavaScript-coding-style-guide.md @@ -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 diff --git a/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md b/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md index fa308f1d22..168183261d 100755 --- a/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md +++ b/zh-cn/contribute/OpenHarmony-JavaScript-coding-style-guide.md @@ -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 -- GitLab