mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Round Infinity with a precision argument returns Infinity (#4272)
* Round Infinity with a precision argument returns Infinity * Also making sure this is true for -Infinity * Tested with _.round(), _.floor() and _.ceil() * Switch to using isFinite to check if number should be rounded * Add tests for rounding NaN now that there is an isFinite check
This commit is contained in:
committed by
John-David Dalton
parent
0b8592a35c
commit
343456d696
@@ -5406,7 +5406,7 @@
|
||||
return function(number, precision) {
|
||||
number = toNumber(number);
|
||||
precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
|
||||
if (precision) {
|
||||
if (precision && Number.isFinite(number)) {
|
||||
// Shift with exponential notation to avoid floating-point issues.
|
||||
// See [MDN](https://mdn.io/round#Examples) for more details.
|
||||
var pair = (toString(number) + 'e').split('e'),
|
||||
|
||||
Reference in New Issue
Block a user