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

Function fx_Math_round

xs/sources/xsMath.c:584–605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

582}
583
584void fx_Math_round(txMachine* the)
585{
586 txNumber arg;
587 mxNanResultIfNoArg;
588 if (XS_INTEGER_KIND == mxArgv(0)->kind) {
589 mxResult->kind = XS_INTEGER_KIND;
590 mxResult->value.integer = mxArgv(0)->value.integer;
591 return;
592 }
593 arg = fxToNumber(the, mxArgv(0));
594 if (c_isnormal(arg) && (-4503599627370495 < arg) && (arg < 4503599627370495)) { // 2 ** 52 - 1
595 if ((arg < -0.5) || (0.5 <= arg))
596 arg = c_floor(arg + 0.5);
597 else if (arg < 0)
598 arg = -0.0;
599 else if (arg > 0)
600 arg = 0.0;
601 }
602 mxResult->kind = XS_NUMBER_KIND;
603 mxResult->value.number = arg;
604 fx_Math_toInteger(the);
605}
606
607void fx_Math_sqrt(txMachine* the)
608{

Callers

nothing calls this directly

Calls 2

fxToNumberFunction · 0.85
fx_Math_toIntegerFunction · 0.85

Tested by

no test coverage detected