From 4949869b5e5824e5805ddd0ae1d64116956ecdd4 Mon Sep 17 00:00:00 2001 From: Lucia Velasco Date: Fri, 2 Mar 2018 22:07:56 +0000 Subject: [PATCH] Allows round up and round ceil to work in the toNearest function. This makes the new tests in the previous commit work. A value of less than half of the first parameter of toNearest will now round up to the nearest multiplication of that first parameter. --- decimal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decimal.js b/decimal.js index d69768e..6504aee 100644 --- a/decimal.js +++ b/decimal.js @@ -2165,7 +2165,7 @@ // If y is not zero, calculate the nearest multiple of y to x. if (y.d[0]) { external = false; - if (rm < 4) rm = [4, 5, 7, 8][rm]; + if (rm === 1 || rm === 3) rm = [4, 5, 7, 8][rm]; x = divide(x, y, 0, rm, 1).times(y); external = true; finalise(x);