mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
LibJS: Add spec comments and check for edge cases in Math.sinh
This commit is contained in:
parent
4306462a95
commit
8de8742b7c
2 changed files with 11 additions and 2 deletions
|
@ -600,9 +600,14 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::log10)
|
|||
// 21.3.2.31 Math.sinh ( x ), https://tc39.es/ecma262/#sec-math.sinh
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::sinh)
|
||||
{
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
auto number = TRY(vm.argument(0).to_number(vm));
|
||||
if (number.is_nan())
|
||||
return js_nan();
|
||||
|
||||
// 2. If n is not finite or n is either +0𝔽 or -0𝔽, return n.
|
||||
if (!number.is_finite_number() || number.is_positive_zero() || number.is_negative_zero())
|
||||
return number;
|
||||
|
||||
// 3. Return an implementation-approximated Number value representing the result of the hyperbolic sine of ℝ(n).
|
||||
return Value(::sinh(number.as_double()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue