Welcome! Please see the About page for a little more info on how this works.
The workaround for negative numbers (https://dev.clojure.org/jira/browse/CLJS-417) results in annoying behavior for floats:
(mod 2.1 3) ; => 2.0999999999999996
Both Clojure and the standard JavaScript modulo return the expected 2.1 here.
Two possible solutions:
Comment made by: dnolen
Patch welcome.
Comment made by: zto
The patch renames cljs.core/mod to double-mod and redefines mod to invoke js-mod directly when both args have the same sign. It includes test cases for the previously failing cases, but I've also tested more exhaustively against the Clojure impl: https://gist.github.com/aw7/a32bd69923c65bddc23fd63ee062833c
Great thanks, have you submitted your Clojure CA?
Yeah, 2h ago.
Comment made by: anmonteiro
Nit: shouldn't the double-mod function be marked as private then?
double-mod
I guess there's no need for double-mod to exist as a separate function at all, I've added a patch where it's inlined into mod.
mod
Comment made by: mfikes
Arg... something in the patch is killing the older JavaScriptCore we run tests with in Travis. My only guess is the additional mod tests may be triggering CLJS-910, but that seems unlikely.