diff options
author | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-03-05 00:02:37 +0700 |
---|---|---|
committer | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-03-06 08:31:21 +0700 |
commit | 1cd99d08893e24f594fa0bd19108225ab3acfa80 (patch) | |
tree | b41005f530d35fc58594b3952f64023a91ed0be9 | |
parent | 02cdea5859956e1bffcdc1f26a188200a529c53a (diff) |
Implement signbit in terms of copysign.
Currently, copysign is broken for negative zero, so this will be
as well.
Fixes #911.
-rw-r--r-- | src/library.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/library.js b/src/library.js index 1676a82c..5b1ed33b 100644 --- a/src/library.js +++ b/src/library.js @@ -5506,6 +5506,14 @@ LibraryManager.library = { return -a; }, copysignf: 'copysign', + __signbit__deps: ['copysign'], + __signbit: function(x) { + // We implement using copysign so that we get support + // for negative zero (once copysign supports that). + return _copysign(1.0, x) < 0; + }, + __signbitf: '__signbit', + __signbitd: '__signbit', hypot: function(a, b) { return Math.sqrt(a*a + b*b); }, |