const tests = [
[-0 x7ffffffen, -2 n, -0 x80000000n],
[-2 n, -2 n, -4 n],
[-1 n, -2 n, -3 n],
[0 n, -2 n, -2 n],
[1 n, -2 n, -1 n],
[2 n, -2 n, 0 n],
[0 x7ffffffen, -2 n, 0 x7ffffffcn],
[0 x7fffffffn, -2 n, 0 x7ffffffdn],
[-0 x7fffffffn, -1 n, -0 x80000000n],
[-0 x7ffffffen, -1 n, -0 x7fffffffn],
[-1 n, -1 n, -2 n],
[0 n, -1 n, -1 n],
[1 n, -1 n, 0 n],
[2 n, -1 n, 1 n],
[0 x7ffffffen, -1 n, 0 x7ffffffdn],
[0 x7fffffffn, -1 n, 0 x7ffffffen],
[-0 x80000000n, 0 n, -0 x80000000n],
[-0 x7fffffffn, 0 n, -0 x7fffffffn],
[-0 x7ffffffen, 0 n, -0 x7ffffffen],
[0 n, 0 n, 0 n],
[1 n, 0 n, 1 n],
[2 n, 0 n, 2 n],
[0 x7ffffffen, 0 n, 0 x7ffffffen],
[0 x7fffffffn, 0 n, 0 x7fffffffn],
[-0 x80000000n, 1 n, -0 x7fffffffn],
[-0 x7fffffffn, 1 n, -0 x7ffffffen],
[-0 x7ffffffen, 1 n, -0 x7ffffffdn],
[1 n, 1 n, 2 n],
[2 n, 1 n, 3 n],
[0 x7ffffffen, 1 n, 0 x7fffffffn],
[-0 x80000000n, 2 n, -0 x7ffffffen],
[-0 x7fffffffn, 2 n, -0 x7ffffffdn],
[-0 x7ffffffen, 2 n, -0 x7ffffffcn],
[2 n, 2 n, 4 n],
[-0 x80000000n, 0 x7ffffffen, -2 n],
[-0 x7fffffffn, 0 x7ffffffen, -1 n],
[-0 x7ffffffen, 0 x7ffffffen, 0 n],
[-0 x80000000n, 0 x7fffffffn, -1 n],
[-0 x7fffffffn, 0 x7fffffffn, 0 n],
[-0 x7ffffffen, 0 x7fffffffn, 1 n],
];
function f(tests) {
for (let test of tests) {
let lhs = test[0 ], rhs = test[1 ], expected = test[2 ];
assertEq(BigInt.asIntN(32 , lhs), lhs);
assertEq(BigInt.asIntN(32 , rhs), rhs);
assertEq(BigInt.asIntN(32 , expected), expected);
let f = Function (`
let lhs = ${lhs}n;
let rhs = ${rhs}n;
assertEq(lhs + rhs, ${expected}n);
assertEq(rhs + lhs, ${expected}n);
`);
for (let j = 0 ; j < 100 ; ++j) {
f();
}
}
}
f(tests);
Messung V0.5 in Prozent C=100 H=20 G=72
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-08-25)
¤
*© Formatika GbR, Deutschland