cljs.math/floor-mod

functionsince v1.11.50Edit
(floor-mod x y)

Source docstring:
Integer modulus x - (floorDiv(x, y) * y). Sign matches y and is in the
range -|y| < r < |y|.
See: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#floorMod-long-long-
Source code @ clojurescript:src/main/cljs/cljs/math.cljs
(defn ^number floor-mod
  {:added "1.11.10"}
  [x y]
  (if-not (and ^boolean (js/Number.isSafeInteger x) ^boolean (js/Number.isSafeInteger y))
    (throw (ex-info "floor-mod called with non-safe-integer arguments"
                    {:x-int? (js/Number.isSafeInteger x) :y-int? (js/Number.isSafeInteger y)}))
    ;; this avoids using floor-div to keep within the safe integer range
    (let [r (long (/ x y))]
      (if (and (xor (< x 0) (< y 0)) (not (== (* r y) x)))
        (- x (* y r) (- y))
        (- x (* y r))))))