1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:57:35 +00:00

LibJS: Add spec comments to Value::to_bigint_int64()

This commit is contained in:
Linus Groh 2022-12-10 00:00:07 +00:00
parent 0d4b798932
commit fb5256b225

View file

@ -826,7 +826,11 @@ static Optional<BigInt*> string_to_bigint(VM& vm, StringView string)
// 7.1.15 ToBigInt64 ( argument ), https://tc39.es/ecma262/#sec-tobigint64
ThrowCompletionOr<i64> Value::to_bigint_int64(VM& vm) const
{
// 1. Let n be ? ToBigInt(argument).
auto* bigint = TRY(to_bigint(vm));
// 2. Let int64bit be (n) modulo 2^64.
// 3. If int64bit ≥ 2^63, return (int64bit - 2^64); otherwise return (int64bit).
return static_cast<i64>(bigint->big_integer().to_u64());
}