aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJez Ng <me@jezng.com>2013-06-06 10:27:17 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-06-07 10:09:12 -0700
commit32dc04d8d17fb7cc4122d692c8fa1ba661a33803 (patch)
treec464228c745912654e3ce24ebacd74a6641bfd81 /src
parent5f2ccad0a399276de4e8426fcd1449e256499815 (diff)
Make lrint more correct. Closes #1265.
Diffstat (limited to 'src')
-rw-r--r--src/library.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js
index 5779327f..2578fda4 100644
--- a/src/library.js
+++ b/src/library.js
@@ -5732,7 +5732,8 @@ LibraryManager.library = {
llround: 'round',
llroundf: 'round',
rint: function(x) {
- return (x > 0) ? -Math.round(-x) : Math.round(x);
+ if (Math.abs(x % 1) !== 0.5) return Math.round(x);
+ return x + x % 2 + ((x < 0) ? 1 : -1);
},
rintf: 'rint',
lrint: 'rint',