diff options
author | Linus Groh <mail@linusgroh.de> | 2022-12-10 00:00:07 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-12-10 11:23:23 +0000 |
commit | fb5256b2256866628eed3914e7e1b20faf350272 (patch) | |
tree | da9f68da3bc4f42ab823aea68f0fe2f7c0a79f06 /Userland/Libraries/LibJS/Runtime | |
parent | 0d4b798932c79a793e3bcc0ce531fe3436274989 (diff) | |
download | serenity-fb5256b2256866628eed3914e7e1b20faf350272.zip |
LibJS: Add spec comments to Value::to_bigint_int64()
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 605c5bfcb7..9ace99bb39 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -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()); } |