This is a “feature” in most programming languages and I think actually corresponds to the standard way division is implemented in the CPU itself (so it has little to do with OCaml). How this was allowed to become the standard I do not know.

One thing is that I get the impression that people who are not familiar with number theory find the following result extremely counter-intuitive : `(-3) / 2 = -2`

I believe it is because they think of integer division as an approximation of real division, rather than as being its own special thing, and from this perspective it makes no sense that making a number negative should change the result. They expect the identities that hold of real division (like `(a*b) / c = a * (b/c)`

) to also hold for integer division. (I say “they” not to belittle the perspective, I totally see where they are coming from.)

But then if you have `(-3) / 2 = -1`

, you need to have `(-3) mod 2 = -1`

to preserve the relation between `/`

and `mod`

that you mention (so you’ll note that the relation does hold in this system).

I tend to think that the behaviour where `mod`

never returns anything negative, in addition to being what a mathematician would expect, is strictly more useful (for what I believe to be the typical use case of modulo over negative numbers in programming, which is indexing into a circular buffer). And I also think that you almost never divide negative numbers, so the useful behaviour for `mod`

should have taken priority when deciding how all this works, and whether `/`

is intuitive or not does not matter much in practice. But I have no idea who took that decision and whether such issues were even considered.