Skip to content

Commit d852c7d

Browse files
ptomatoMs2ger
authored andcommitted
Add clarifying comment in RoundNumberToIncrementAsIfPositive
While going over this code I was very confused by this line. I've added a comment to explain it.
1 parent 7867b02 commit d852c7d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

polyfill/lib/ecmascript.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4038,6 +4038,8 @@ export function RoundNumberToIncrementAsIfPositive(quantity, increment, mode) {
40384038
r1 = quotient;
40394039
r2 = quotient.add(1);
40404040
}
4041+
// Similar to the comparison in RoundNumberToIncrement, but multiplied by an
4042+
// extra sign to make sure we treat it as positive
40414043
const cmp = remainder.times(2).abs().compare(increment) * (quantity.lt(0) ? -1 : 1);
40424044
const even = r1.isEven();
40434045
const rounded = quotient.times(increment).eq(quantity)

0 commit comments

Comments
 (0)