Implement missing hyperbolic Math functions from ES6 (#3670)

Math.cosh, Math.sinh, Math.tanh

C implementation ported from fdlibm.

Part of Issue #3568

JerryScript-DCO-1.0-Signed-off-by: Rafal Walczyna r.walczyna@samsung.com
This commit is contained in:
Rafal Walczyna
2020-04-21 12:34:38 +02:00
committed by GitHub
parent d1bf9635c7
commit bcd5ff3f40
11 changed files with 718 additions and 12 deletions
+22
View File
@@ -0,0 +1,22 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var p_zero = 0.0;
var n_zero = -p_zero;
assert(isNaN(Math.cosh(NaN)));
assert(Math.cosh(p_zero) === 1);
assert(Math.cosh(n_zero) === 1);
assert(Math.cosh(Number.POSITIVE_INFINITY) === Number.POSITIVE_INFINITY);
assert(Math.cosh(Number.NEGATIVE_INFINITY) === Number.POSITIVE_INFINITY);
+27
View File
@@ -0,0 +1,27 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var p_zero = 0.0;
var n_zero = -p_zero;
function isSameZero (x, y)
{
return x === 0 && (1 / x) === (1 / y);
}
assert(isNaN(Math.sinh(NaN)));
assert(isSameZero(Math.sinh(p_zero), p_zero));
assert(isSameZero(Math.sinh(n_zero), n_zero));
assert(Math.sinh(Number.POSITIVE_INFINITY) === Number.POSITIVE_INFINITY);
assert(Math.sinh(Number.NEGATIVE_INFINITY) === Number.NEGATIVE_INFINITY);
+27
View File
@@ -0,0 +1,27 @@
// Copyright JS Foundation and other contributors, http://js.foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var p_zero = 0.0;
var n_zero = -p_zero;
function isSameZero (x, y)
{
return x === 0 && (1 / x) === (1 / y);
}
assert(isNaN(Math.tanh(NaN)));
assert(isSameZero(Math.tanh(p_zero), p_zero));
assert(isSameZero(Math.tanh(n_zero), n_zero));
assert(Math.tanh(Number.POSITIVE_INFINITY) === 1);
assert(Math.tanh(Number.NEGATIVE_INFINITY) === -1);