MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxBigInt_xor

Function fxBigInt_xor

xs/sources/xsBigInt.c:1193–1227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1191}
1192
1193txBigInt *fxBigInt_xor(txMachine* the, txBigInt *r, txBigInt *a, txBigInt *b)
1194{
1195 txBigInt *aa, *bb;
1196 if (a->sign) {
1197 if (b->sign)
1198 goto XOR_MINUS_MINUS;
1199 aa = a;
1200 a = b;
1201 b = aa;
1202 goto XOR_PLUS_MINUS;
1203 }
1204 if (b->sign)
1205 goto XOR_PLUS_MINUS;
1206 return fxBigInt_fit(the, fxBigInt_uxor(the, r, a, b));
1207XOR_PLUS_MINUS:
1208// GMP: -(OP1 ^ (-OP2)) == -(OP1 ^ ~(OP2 - 1)) == ~(OP1 ^ ~(OP2 - 1)) + 1 == (OP1 ^ (OP2 - 1)) + 1
1209 if (r == NULL)
1210 r = fxBigInt_alloc(the, MAX(a->size, b->size) + 1);
1211 bb = fxBigInt_usub(the, NULL, b, (txBigInt *)&gxBigIntOne);
1212 r = fxBigInt_uxor(the, r, a, bb);
1213 r = fxBigInt_uadd(the, r, r, (txBigInt *)&gxBigIntOne);
1214 r->sign = 1;
1215 fxBigInt_free(the, bb);
1216 return fxBigInt_fit(the, r);
1217XOR_MINUS_MINUS:
1218// GMP: (-OP1) ^ (-OP2) == ~(OP1 - 1) ^ ~(OP2 - 1) == (OP1 - 1) ^ (OP2 - 1)
1219 if (r == NULL)
1220 r = fxBigInt_alloc(the, MAX(a->size, b->size));
1221 aa = fxBigInt_usub(the, NULL, a, (txBigInt *)&gxBigIntOne);
1222 bb = fxBigInt_usub(the, NULL, b, (txBigInt *)&gxBigIntOne);
1223 r = fxBigInt_uxor(the, r, aa, bb);
1224 fxBigInt_free(the, bb);
1225 fxBigInt_free(the, aa);
1226 return fxBigInt_fit(the, r);
1227}
1228
1229txBigInt *fxBigInt_uxor(txMachine* the, txBigInt *r, txBigInt *a, txBigInt *b)
1230{

Callers

nothing calls this directly

Calls 6

fxBigInt_fitFunction · 0.85
fxBigInt_uxorFunction · 0.85
fxBigInt_allocFunction · 0.85
fxBigInt_usubFunction · 0.85
fxBigInt_uaddFunction · 0.85
fxBigInt_freeFunction · 0.85

Tested by

no test coverage detected