From 377e2d87c88893a8a1e4e3cd04da5a8893ea7a7b Mon Sep 17 00:00:00 2001 From: LinWei <1021069119@qq.com> Date: Wed, 28 Nov 2018 23:12:21 +0800 Subject: [PATCH] fix: limit the precision when the precision is negative (#4085) --- .internal/createRound.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.internal/createRound.js b/.internal/createRound.js index 8729aa958d..b520ba1343 100644 --- a/.internal/createRound.js +++ b/.internal/createRound.js @@ -8,7 +8,7 @@ function createRound(methodName) { const func = Math[methodName] return (number, precision) => { - precision = precision == null ? 0 : Math.min(precision, 292) + precision = precision == null ? 0 : (precision >= 0 ? Math.min(precision, 292) : Math.max(precision, -292)) if (precision) { // Shift with exponential notation to avoid floating-point issues. // See [MDN](https://mdn.io/round#Examples) for more details.