The implementation of the quot and rem functions are needlessly complicated. Currently they are:
However all numbers in js are doubles already, so all this is unnecessary:
Notice that "rem" is simply js-mod, and I'm not sure why no one noticed this before. I keep js-mod for now since a lot of code uses it, and if cljs ever grows a number tower the distinction may be important.
Patch attached, which also:
Creates a macro version of quot and rem.
Updates documentation for quot, rem, js-mod and mod for clarity.
Implement fix (private function to round to zero) with ES6 Math.trunc() if available.
Existing quot and rem tests pass, although there could be some better tests of edge cases (negative decimal num or div, NaN and +-Infinity args).
Patch now applies. I only tested with Nashorn:
Patch cleaned up
I also manually ran some of the unit tests in bootstrapped ClojureScript built with the patch.
Since this is a low-level numerics update, also ran the unit tests through ChackraCore (successfully).
CLJS-1164-1.patch no longer applies to master