//////////////////////////////////////////////////////////////////////// // Some simple smoke tests
// 2^63
let x80 = 0x8000000000000000n;
// "normalize" `x` so it falls into uint64_t range (a lame kludge) function normalize(x) { if (x < 0n) return x + x80 + x80; return x;
}
function tryAddI128(a, b, c, d, expected) {
assertEq(expected.length, 2);
let actual = i.exports.doAddI128(a, b, c, d);
assertEq(actual.length, 2);
assertEq(normalize(actual[0]), normalize(expected[0]));
assertEq(normalize(actual[1]), normalize(expected[1]));
}
function trySubI128(a, b, c, d, expected) {
assertEq(expected.length, 2);
let actual = i.exports.doSubI128(a, b, c, d);
assertEq(actual.length, 2);
assertEq(normalize(actual[0]), normalize(expected[0]));
assertEq(normalize(actual[1]), normalize(expected[1]));
}
function tryMulI64WideU(a, b, expected) {
assertEq(expected.length, 2);
let actual = i.exports.doMulI64WideU(a, b);
assertEq(actual.length, 2);
assertEq(normalize(actual[0]), normalize(expected[0]));
assertEq(normalize(actual[1]), normalize(expected[1]));
}
function tryMulI64WideS(a, b, expected) {
assertEq(expected.length, 2);
let actual = i.exports.doMulI64WideS(a, b);
assertEq(actual.length, 2);
assertEq(normalize(actual[0]), normalize(expected[0]));
assertEq(normalize(actual[1]), normalize(expected[1]));
}
// Addition
// format is: --lhs-- --rhs-- result // lo, hi, lo, hi, [lo, hi]
tryAddI128( 2n, 1n, 4n, 3n, [6n, 4n]); // no carry at midpoint
tryAddI128( x80, 22n, x80, 33n, [0n, 56n]); // carry at midpoint
// carry out of neither
tryAddI128(0x02a74ec1865d36e3n, 0x30fe727e0ffbaf31n, 0xb432733713c75e66n, 0x457b20ce3d706ea3n,
[0xb6d9c1f89a249549n, 0x7679934c4d6c1dd4n]);
// carry out of lo
tryAddI128(0xcd0e81861923459bn, 0x30fe727e0ffbaf31n, 0xb432733713c75e66n, 0x457b20ce3d706ea3n,
[0x8140f4bd2ceaa401n, 0x7679934c4d6c1dd5n]);
// carry out of hi
tryAddI128(0x02a74ec1865d36e3n, 0xd74276b90c9d680bn, 0xb432733713c75e66n, 0x457b20ce3d706ea3n,
[0xb6d9c1f89a249549n, 0x1cbd97874a0dd6aen]);
// carry out of both
tryAddI128(0xcd0e81861923459bn, 0xd74276b90c9d680bn, 0xb432733713c75e66n, 0x457b20ce3d706ea3n,
[0x8140f4bd2ceaa401n, 0x1cbd97874a0dd6afn]);
// Subtraction
// format is: --lhs-- --rhs-- result // lo, hi, lo, hi, [lo, hi]
trySubI128(88n, 9999n, 66n, 4444n, [22n, 5555n]); // no borrow at midpoint
trySubI128(88n, 9999n, 99n, 4444n, [-11n, 5554n]); // borrow at midpoint
// Widening multiplies // format is: -result- // operand operand [hi, lo]
// Signed and unsigned produce the same result.
tryMulI64WideU(123n, 456n, [56088n, 0n]);
tryMulI64WideS(123n, 456n, [56088n, 0n]);
// Signed and unsigned produce the same result; but bits[127:64] are now used
tryMulI64WideU(123999888777n, 456777666555n, [8875542349269292115n, 3070n]);
tryMulI64WideS(123999888777n, 456777666555n, [8875542349269292115n, 3070n]);
// Signed and unsigned produce different results
tryMulI64WideU(0x8123ffffeeeeddddn, 456777666555n,
[-6687103016203617617n, 230424036496n]);
tryMulI64WideS(0x8123ffffeeeeddddn, 456777666555n,
[11759641057505933999n, 18446743847355921557n]);
// As above pair, but with operands swapped. Results should be the same // as above.
tryMulI64WideU(456777666555n, 0x8123ffffeeeeddddn,
[-6687103016203617617n, 230424036496n]);
tryMulI64WideS(456777666555n, 0x8123ffffeeeeddddn,
[11759641057505933999n, 18446743847355921557n]);
assertErrorMessage(() => wasmEvalText(`
(module
(func (param i64 i64) (result i64)
local.get 0
local.get 1
i64.mul_wide_s)
)`), Error, /unused values not explicitly dropped by end of block/);
assertErrorMessage(() => wasmEvalText(`
(module
(func (param i64) (result i64 i64)
local.get 0
i64.mul_wide_s)
)`), Error, /popping value from empty stack/);
assertErrorMessage(() => wasmEvalText(`
(module
(func (param i64 i64) (result i64)
local.get 0
local.get 1
i64.mul_wide_u)
)`), Error, /unused values not explicitly dropped by end of block/);
assertErrorMessage(() => wasmEvalText(`
(module
(func (param i64) (result i64 i64)
local.get 0
i64.mul_wide_u)
)`), Error, /popping value from empty stack/);
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.11Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-12)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.