commit
message
Formulas.ASIN written and tested.
author
Ben Vogt <[email protected]>
date
2017-01-16 23:53:23
stats
2 file(s) changed,
24 insertions(+),
3 deletions(-)
files
src/RawFormulas.ts
tests/FormulasTest.ts
1diff --git a/src/RawFormulas.ts b/src/RawFormulas.ts
2index fbcefe1..6d42607 100644
3--- a/src/RawFormulas.ts
4+++ b/src/RawFormulas.ts
5@@ -245,8 +245,19 @@ var ASIN = function (value?) {
6 return Math.asin(value);
7 };
8
9+/**
10+ * Returns the inverse hyperbolic sine of a number.
11+ * @param value The value for which to calculate the inverse hyperbolic sine.
12+ * @returns {number} inverse hyperbolic sine of input
13+ * @constructor
14+ */
15+var ASINH = function (value?) {
16+ checkArgumentsLength(arguments, 1);
17+ value = valueToNumber(value);
18+ return Math.log(value + Math.sqrt(value * value + 1));
19+};
20+
21
22-var ASINH = Formula["ASINH"];
23 var ATAN = Formula["ATAN"];
24 var ATAN2 = function (x, y) {
25 return Math.atan2(y, x);
26diff --git a/tests/FormulasTest.ts b/tests/FormulasTest.ts
27index 9ad9499..bc9e2fe 100644
28--- a/tests/FormulasTest.ts
29+++ b/tests/FormulasTest.ts
30@@ -120,6 +120,7 @@ catchAndAssertEquals(function() {
31 return ARABIC(10);
32 }, ERRORS.VALUE_ERROR);
33
34+
35 // Test ASIN
36 assertEquals(ASIN(0), 0);
37 assertEquals(ASIN(1), 1.5707963267948966);
38@@ -133,7 +134,16 @@ catchAndAssertEquals(function() {
39 }, ERRORS.VALUE_ERROR);
40
41
42-assertEquals(ASINH(0.1), 0.09983407889920758);
43+// Test ASINH
44+assertEquals(ASINH(1), 0.8813735870195429);
45+assertEquals(ASINH(0), 0);
46+assertEquals(ASINH("1"), 0.8813735870195429);
47+assertEquals(ASINH(false), 0);
48+assertEquals(ASINH(true), 0.8813735870195429);
49+catchAndAssertEquals(function() {
50+ return ASINH("str");
51+}, ERRORS.VALUE_ERROR);
52+
53
54 assertEquals(ATAN(0.1), 0.09966865249116204);
55