function/macro | since v0.0-1552 | Edit |
(js-mod n d)
Returns the modulus of dividing numerator n
by denominator d
, with JavaScript's
original behavior for negative numbers.
Returns NaN
when d
is 0 (divide by 0 error).
Equivalent to x % y
in JavaScript.
(js-mod -5 3)
;;=> -2
(js-mod 5 3)
;;=> 2
(js-mod 5 0)
;;=> NaN
Modulus of num and div with original javascript behavior. i.e. bug for negative numbers
(defn js-mod
[n d]
(cljs.core/js-mod n d))
(core/defmacro ^::ana/numeric js-mod [num div]
(core/list 'js* "(~{} % ~{})" num div))