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

Function fx_BigInt_asAux

xs/sources/xsBigInt.c:118–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118txNumber fx_BigInt_asAux(txMachine* the)
119{
120 txNumber value, index;
121 if (mxArgc < 1)
122 index = 0;
123 else {
124 if (mxArgv(0)->kind == XS_UNDEFINED_KIND)
125 index = 0;
126 else {
127 value = fxToNumber(the, mxArgv(0));
128 if (c_isnan(value))
129 index = 0;
130 else {
131 value = c_trunc(value);
132 if (value < 0)
133 mxRangeError("index < 0");
134 index = value;
135 if (index <= 0)
136 index = 0;
137 else if (index > C_MAX_SAFE_INTEGER)
138 index = C_MAX_SAFE_INTEGER;
139 if (value != index)
140 mxRangeError("invalid index");
141 }
142 }
143 }
144 if (mxArgc < 2)
145 mxTypeError("no bigint");
146 return index;
147}
148
149void fx_BigInt_asIntN(txMachine* the)
150{

Callers 2

fx_BigInt_asIntNFunction · 0.85
fx_BigInt_asUintNFunction · 0.85

Calls 1

fxToNumberFunction · 0.85

Tested by

no test coverage detected