Baseline Widely available
BigInt.asIntN
éææ¹æ³å° BigInt
å¼è½¬æ¢ä¸ºä¸ä¸ª -2^(width-1)
ä¸ 2^(width-1)-1
ä¹é´çæç¬¦å·æ´æ°ã
const I64_CEIL = 2n ** 63n;
console.log(BigInt.asIntN(64, I64_CEIL - 1n));
// 9223372036854775807n (2n ** 64n - 1n, the maximum non-wrapping value)
console.log(BigInt.asIntN(64, I64_CEIL));
// -9223372036854775808n (wraps to min value)
console.log(BigInt.asIntN(64, I64_CEIL + 1n));
// -9223372036854775807n (min value + 1n)
console.log(BigInt.asIntN(64, I64_CEIL * 2n));
// 0n (wrapped around to zero)
console.log(BigInt.asIntN(64, -I64_CEIL * -42n));
// 0n (also wraps on negative multiples)
è¯æ³
BigInt.asIntN(width, bigint);åæ°
width
å¯å卿´æ°ç使°ã
bigint
è¦åå¨å¨æå®ä½æ°ä¸çæ´æ°ã
bigint
模 (modulo) 2^width
ä½ä¸ºæç¬¦å·æ´æ°çå¼ã
BigInt.asIntN()
æ¹æ³å¯¹äºä¿æå¨ 64 ä½ (64-bit) ç®æ°èå´å
é常æç¨ã
const max = 2n ** (64n - 1n) - 1n;
BigInt.asIntN(64, max);
// ⪠9223372036854775807n
BigInt.asIntN(64, max + 1n);
// ⪠-9223372036854775808n
// negative because of overflow
è§è æµè§å¨å
¼å®¹æ§ 请åé
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4