Permalink
Browse files

Fixed % to use REM instead of MOD (result differs on negative numbers)

  • Loading branch information...
vsedach authored and marijnh committed Oct 7, 2012
1 parent 1494087 commit b0920d6faabfb7b1324754dab45e95f76f10d84b
Showing with 6 additions and 2 deletions.
  1. +1 −1 inline-op.lisp
  2. +1 −1 operators.lisp
  3. +4 −0 test.js
View
@@ -61,7 +61,7 @@
(if (zerop ,val) (- 0d0) (js- 0 ,val)))))
(defnumop :* `(* ,lhs ,rhs))
-(defnumop :% `(mod ,lhs ,rhs))
+(defnumop :% `(rem ,lhs ,rhs))
(defnumop :< `(< ,lhs ,rhs))
(defnumop :> `(> ,lhs ,rhs))
View
@@ -74,7 +74,7 @@
(if (zerop rs)
(nan)
(complicated-numeric-op
- ls rs mod (nan)
+ ls rs rem (nan)
(nan) (nan) (nan) (nan) ls ls (nan) (nan)))))
(defun js^ (ls rs)
View
@@ -549,6 +549,10 @@ function test_40() {
}
}
+function test_41() {
+ $eq(-12 % 7, -5);
+}
+
function runTests() {
var failures = [];
var run = 0;

0 comments on commit b0920d6

Please sign in to comment.