This message was deleted.
# getting-started
s
This message was deleted.
e
div is to rem as floorDiv is to floorMod
in other words, they come in pairs; mod & floorDiv are not from the same pair
for all x and non-zero y, x == x / y * y + x % y (aka x == x.div(y) * y + x.rem(y)) x == floorDiv(x, y) * y + floorMod(x, y)
@Ruckus I was referring to java.lang.Math.floorMod&floorDiv. I haven't checked if Kotlin's new operators line up with those.
looks like they do, although the naming is unfortunate
IMO everything should have been named div/mod and quot/rem from the start, but it's too late now
if you're working on positive numbers only, then none of it matters, both sets of operators have the same result 🙂
the difference is that Java's (and Kotlin's) x % y keeps the sign of x, while floorMod(x, y) keeps the sign of y. the result of x / y and floorDiv(x, y) are consistent with that to maintain the previous invariant