I noticed that for integer-division there exists div_trunc_by (rounds towards zero), div_ceil_by (rounds up), but not div_floor_by (would round down). Are there plans to still add div_floor_by?
In my date/time library I make use of the Neiri/Schneider algorithms, and these make use of div_floor_by-type integer division. Possibly there's an equivalent way to get the same output, but I don't really understand the algorithm I'm copying :sweat_smile:, so I'm pretty much doing a line-by-line transformation from the Zig-version of the algorithm. My current workaround of doing float division and then casting the result back to an integer is certainly suboptimal, hence the interest.
we should add it! :+1:
can you open an issue for that?
Sure thing!
https://github.com/roc-lang/roc/issues/10085
Jasper Woudenberg has marked this topic as resolved.
@Jasper Woudenberg how's this look? https://github.com/roc-lang/roc/pull/10086/changes
Awesome! I was a bit surprised it needs some conditional logic around it and can't be lowered directly to assembly or something, but best I can tell from taking a look at the @divFloor primitive in Zig they have a similar thing going on.
Last updated: Jul 23 2026 at 13:15 UTC