mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
fix: limit the precision when the precision is negative (#4085)
This commit is contained in:
committed by
John-David Dalton
parent
c3740e0847
commit
377e2d87c8
@@ -8,7 +8,7 @@
|
|||||||
function createRound(methodName) {
|
function createRound(methodName) {
|
||||||
const func = Math[methodName]
|
const func = Math[methodName]
|
||||||
return (number, precision) => {
|
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) {
|
if (precision) {
|
||||||
// Shift with exponential notation to avoid floating-point issues.
|
// Shift with exponential notation to avoid floating-point issues.
|
||||||
// See [MDN](https://mdn.io/round#Examples) for more details.
|
// See [MDN](https://mdn.io/round#Examples) for more details.
|
||||||
|
|||||||
Reference in New Issue
Block a user