When working with angles I sometimes miss the Python "true" modulus operator for floating point values:
>>> -10.0 % 360.0
350.0
>>>
The Roc equivalent I think returns a remainder:
» -30.0 % 360.0
-30.0
I realize I can always do:
» -10.0 - 360.0 * -10.0.div_floor_by(360.0)
350.0
But a method or operator would be nice to have.
I feel like I've seen a programming language out there that has two operators for mod (with both semantics for negatives). It's definitely a bug-prone thing.
A true_mod() function could also work
FWIW, Odin and CoffeeScript both use % for the remainder (-10 % 360 = -10) and %% for the modulo (-10 %% 360 = 350).
Note: almost all languages that distinguish the two call them remainder and modulo, with the results shown above. The only exception I know of is Odin which oddly reverses this convention (it might just be a mistake in their docs).
Last updated: Nov 26 2026 at 20:35 UTC