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

Function fx_BigInt

xs/sources/xsBigInt.c:96–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96void fx_BigInt(txMachine* the)
97{
98 if (mxHasTarget)
99 mxTypeError("new: BigInt");
100 if (mxArgc > 0)
101 *mxResult = *mxArgv(0);
102 fxToPrimitive(the, mxResult, XS_NUMBER_HINT);
103 if (mxResult->kind == XS_NUMBER_KIND) {
104 int fpclass = c_fpclassify(mxResult->value.number);
105 txNumber check = c_trunc(mxResult->value.number);
106 if ((fpclass != C_FP_NAN) && (fpclass != C_FP_INFINITE) && (mxResult->value.number == check))
107 fxNumberToBigInt(the, mxResult);
108 else
109 mxRangeError("cannot coerce number to bigint");
110 }
111 else if (mxResult->kind == XS_INTEGER_KIND) {
112 fxIntegerToBigInt(the, mxResult);
113 }
114 else
115 fxToBigInt(the, mxResult, 1);
116}
117
118txNumber fx_BigInt_asAux(txMachine* the)
119{

Callers

nothing calls this directly

Calls 5

fxToPrimitiveFunction · 0.85
c_fpclassifyFunction · 0.85
fxNumberToBigIntFunction · 0.85
fxIntegerToBigIntFunction · 0.85
fxToBigIntFunction · 0.85

Tested by

no test coverage detected