In my opinion neither are used sufficiently often to justify taking up a valuable ASCII symbol (same with xor).
In my opinion neither are used sufficiently often to justify taking up a valuable ASCII symbol (same with xor).
As one simple example, it is frequently useful to map floats into the range [0, 2π), but I have never once wanted to map positive floats into the range [0, 2π) while negative floats get mapped into (–2π, 0] by the same code.
- https://github.com/JuliaLang/julia/issues/14826
mod(-eps(), 4.0)
- https://github.com/JuliaLang/julia/issues/17415 fld(1.0,0.2)
- https://github.com/JuliaLang/julia/issues/3127 mod(1.0,0.1)
- https://github.com/JuliaLang/julia/issues/3104 mod(0.95,0.01)
I'm pretty sure there are more issues.re: mod 2pi, typically it is most accurate to reduce to (-pi,pi) (i.e. division rounding to nearest). Also to get it accurate you need fancy range reduction algorithms, hence julia has rem2pi https://docs.julialang.org/en/stable/base/math/#Base.Math.re...
These examples don’t really have much bearing on the general usefulness of “remainder” vs. “modulo” though.
I don’t know what is available as chip instructions, I could certainly believe hardware designers made the wrong choice.
[0] http://www.lispworks.com/documentation/lw50/CLHS/Body/f_floo...
[1] http://www.lispworks.com/documentation/lw50/CLHS/Body/f_mod_...