The advantage of mapping ÷ to fld
is that then %
needs to be mod
, which is not so uncommon to use with a negative first argument. Both rem
and mod
give you a useful cyclic behavior for positive numbers. If you go past zero mod
keeps being cyclic, whereas rem
makes a sign shift and goes over to a cycle with negative numbers. I’m sure there’s some context where rem
is useful with negative first argument, but I’m yet to find it. In my experience mod
is always the operator you want and if you carelessly use %
it’s an invitation for bugs.
I’m not generally enthusiastic about Python but this is something they got right, and Julia (and many other languages) sadly didn’t.