v2
7/6/2023 by vrxgqpr93fcj -00
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
const count = 1000;
const nums = crypto.getRandomValues(new Uint32Array(count));
const bools = Array.from(nums, (_) => Math.random() < 0.5);
const result = [];
const view = new DataView(new ArrayBuffer(8));

function test1_wrong(low, high, isUnsigned) {
    const unsigned = (BigInt(high >>> 0) << BigInt(32)) | BigInt(low >>> 0);
    return unsigned;
}

function test1(low, high, isUnsigned) {
    const unsigned = (BigInt(high >>> 0) << BigInt(32)) | BigInt(low >>> 0);
    if (!isUnsigned && (unsigned & BigInt(1) << BigInt(63))) {
        return unsigned - (BigInt(1) << BigInt(64));
    }
    return unsigned;
}

function test1_literals(low, high, isUnsigned) {
    const unsigned = (BigInt(high >>> 0) << 32n) | BigInt(low >>> 0);
    if (!isUnsigned && (unsigned & (1n << 63n))) {
        return unsigned - (1n << 64n);
    }
    return unsigned;
}


function test2(low, high, isUnsigned) {
	view.setUint32(0, low, true);
	view.setUint32(4, high, true);
	return isUnsigned ? view.getBigUint64(0, true) : view.getBigInt64(0, true);
}
delete caserun single casemove downdrag and drop case


ready



for (let i=0; i < count; i += 2) {
	result.push(test1_wrong(nums[i+1], nums[i], bools[i]));
}
delete caserun single casemove upmove downdrag and drop case


ready



for (let i=0; i < count; i += 2) {
	result.push(test1(nums[i+1], nums[i], bools[i]));
}
delete caserun single casemove upmove downdrag and drop case


ready



for (let i=0; i < count; i += 2) {
	result.push(test1_literals(nums[i+1], nums[i], bools[i]));
}
delete caserun single casemove updrag and drop case


ready



for (let i=0; i < count; i += 2) {
	result.push(test2(nums[i+1], nums[i], bools[i]));
}
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN