struct tnum tnum_or(struct tnum a, struct tnum b)
{
u64 v, mu;
v = a.value | b.value;
mu = a.mask | b.mask; return TNUM(v, mu & ~v);
}
struct tnum tnum_xor(struct tnum a, struct tnum b)
{
u64 v, mu;
v = a.value ^ b.value;
mu = a.mask | b.mask; return TNUM(v & ~mu, mu);
}
/* Generate partial products by multiplying each bit in the multiplier (tnum a) *withthemultiplicand(tnumb),andaddthepartialproductsafter *appropriatelybit-shiftingthem.Insteadofdirectlyperformingtnumaddition *onthegeneratedpartialproducts,equivalenty,decomposeeachpartial *productintotwotnums,consistingofthevalue-sum(acc_v)andthe *mask-sum(acc_m)andthenperformtnumadditiononthem.Thefollowingpaper *explainsthealgorithminmoredetail:https://arxiv.org/abs/2105.05398.
*/ struct tnum tnum_mul(struct tnum a, struct tnum b)
{
u64 acc_v = a.value * b.value; struct tnum acc_m = TNUM(0, 0);
while (a.value || a.mask) { /* LSB of tnum a is a certain 1 */ if (a.value & 1)
acc_m = tnum_add(acc_m, TNUM(0, b.mask)); /* LSB of tnum a is uncertain */ elseif (a.mask & 1)
acc_m = tnum_add(acc_m, TNUM(0, b.value | b.mask)); /* Note: no case for LSB is certain 0 */
a = tnum_rshift(a, 1);
b = tnum_lshift(b, 1);
} return tnum_add(TNUM(acc_v, 0), acc_m);
}
bool tnum_overlap(struct tnum a, struct tnum b)
{
u64 mu;
/* Note that if a and b disagree - i.e. one has a 'known 1' where the other has *a'known0'-thiswillreturna'known1'forthatbit.
*/ struct tnum tnum_intersect(struct tnum a, struct tnum b)
{
u64 v, mu;
v = a.value | b.value;
mu = a.mask & b.mask; return TNUM(v & ~mu, mu);
}
¤ 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.0.12Bemerkung:
(vorverarbeitet am 2026-09-28)
¤
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.