mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
LibJS: Add spec comments and check for edge cases in Math.asinh
This commit is contained in:
parent
6bdf021b0c
commit
68aeeea5d2
2 changed files with 14 additions and 1 deletions
|
@ -337,7 +337,15 @@ JS_DEFINE_NATIVE_FUNCTION(MathObject::asin)
|
|||
// 21.3.2.5 Math.asinh ( x ), https://tc39.es/ecma262/#sec-math.asinh
|
||||
JS_DEFINE_NATIVE_FUNCTION(MathObject::asinh)
|
||||
{
|
||||
return Value(::asinh(TRY(vm.argument(0).to_number(vm)).as_double()));
|
||||
// 1. Let n be ? ToNumber(x).
|
||||
auto number = TRY(vm.argument(0).to_number(vm));
|
||||
|
||||
// 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 inverse hyperbolic sine of ℝ(n).
|
||||
return Value(::asinh(number.as_double()));
|
||||
}
|
||||
|
||||
// 21.3.2.6 Math.atan ( x ), https://tc39.es/ecma262/#sec-math.atan
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue