1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2024-10-27 20:34:12 +00:00

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.
This commit is contained in:
Lucia Velasco 2018-03-02 22:07:56 +00:00
parent caaba6d513
commit 4949869b5e

View File

@ -2165,7 +2165,7 @@
// If y is not zero, calculate the nearest multiple of y to x. // If y is not zero, calculate the nearest multiple of y to x.
if (y.d[0]) { if (y.d[0]) {
external = false; 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); x = divide(x, y, 0, rm, 1).times(y);
external = true; external = true;
finalise(x); finalise(x);