Hacker News new | ask | show | jobs
by thedufer 4518 days ago
The "standard modulo" is actually a remainder operator, and is a js-specific thing. Most languages implement the "true mathematical modulo", aka modulo.

One reason this is useful is if you want an array to wrap around. With modulo, you just index on `index % length` and all is well. But with remainder, this will only do what you want for `index >= 0`, because it can give negative outputs, given negative inputs.