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

Function fxBigIntCompare

xs/sources/xsBigInt.c:333–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331}
332
333txBoolean fxBigIntCompare(txMachine* the, txBoolean less, txBoolean equal, txBoolean more, txSlot* left, txSlot* right)
334{
335 int result;
336 txNumber delta = 0;
337 if (mxBigIntIsNaN(&left->value.bigint))
338 return less & more & !equal;
339 if (right->kind == XS_STRING_KIND)
340 fxStringToBigInt(the, right, 1);
341 if ((right->kind != XS_BIGINT_KIND) && (right->kind != XS_BIGINT_X_KIND)) {
342 fxToNumber(the, right);
343 result = c_fpclassify(right->value.number);
344 if (result == C_FP_NAN)
345 return less & more & !equal;
346 if (result == C_FP_INFINITE)
347 return (right->value.number > 0) ? less : more;
348 delta = right->value.number - c_trunc(right->value.number);
349 fxNumberToBigInt(the, right);
350 }
351 if (mxBigIntIsNaN(&right->value.bigint))
352 return less & more & !equal;
353 result = fxBigInt_comp(&left->value.bigint, &right->value.bigint);
354 if (result < 0)
355 return less;
356 if (result > 0)
357 return more;
358 if (delta > 0)
359 return less;
360 if (delta < 0)
361 return more;
362 return equal;
363}
364
365void fxBigIntDecode(txMachine* the, txSize size)
366{

Callers

nothing calls this directly

Calls 5

fxStringToBigIntFunction · 0.85
fxToNumberFunction · 0.85
c_fpclassifyFunction · 0.85
fxNumberToBigIntFunction · 0.85
fxBigInt_compFunction · 0.85

Tested by

no test coverage detected