summaryrefslogtreecommitdiff
path: root/lib/js/urweb.js
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-12-03 09:44:07 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2011-12-03 09:44:07 -0500
commit7136358c17f8193173e8a0a9469821039212d879 (patch)
tree55e7ce9758b2233896d59392e6b86614abab533a /lib/js/urweb.js
parentd35896d2f29d23c3cd4c180f9249e44ebf7ed208 (diff)
Catching integer divisions by zero
Diffstat (limited to 'lib/js/urweb.js')
-rw-r--r--lib/js/urweb.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index d7bb7b6f..f05957a0 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -19,9 +19,9 @@ function plus(x, y) { return x + y; }
function minus(x, y) { return x - y; }
function times(x, y) { return x * y; }
function div(x, y) { return x / y; }
-function divInt(x, y) { var n = x / y; return n < 0 ? Math.ceil(n) : Math.floor(n); }
+function divInt(x, y) { if (y == 0) er("Division by zero"); var n = x / y; return n < 0 ? Math.ceil(n) : Math.floor(n); }
function mod(x, y) { return x % y; }
-function modInt(x, y) { var n = x % y; return n < 0 ? Math.ceil(n) : Math.floor(n); }
+function modInt(x, y) { if (y == 0) er("Division by zero"); var n = x % y; return n < 0 ? Math.ceil(n) : Math.floor(n); }
function lt(x, y) { return x < y; }
function le(x, y) { return x <= y; }