Number vs BigInt bitflag retrieve

Benchmark created on


Setup

/**
 * @param {number} num
 * @param {number} idx
 */
function getBitNumber(num, idx) {
	return !!((num >>> idx) & 1);
}

/**
 * @param {bigint} num
 * @param {bigint} idx
 */
function getBitBigInt(num, idx) {
	return !!((num >> idx) & 1n);
}

Test runner

Ready to run.

Testing in
TestOps/sec
Number bit get
getBitNumber(0b10101010101010101010101010101010, 25)
ready
BigInt bit get
getBitBigInt(0b10101010101010101010101010101010n, 25n)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.