I32/i32, i64/i64, round down?

As a followup to Is i32 / always round towards 0?

what is the idiomatic way to do "round down" for i32/i32 and i64/i64 ?

By "round down x/y" I mean

floor( (x as arbitrary precision) / (y as arbitrary precision) )

If y > 0, then:

x.div_euclid(y)

For y < 0 that's different from rounding down, but (arguably) is even more logical than flooring (even though Knuth didn't think of it in his books and defines his div to floor).

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.