| 147 | } |
| 148 | |
| 149 | void fx_BigInt_asIntN(txMachine* the) |
| 150 | { |
| 151 | txInteger index = (txInteger)fx_BigInt_asAux(the); |
| 152 | txBigInt* arg = fxToBigInt(the, mxArgv(1), 1); |
| 153 | txBigInt* result; |
| 154 | if (fxBigInt_iszero(arg)) { |
| 155 | result = fxBigInt_dup(the, arg); |
| 156 | } |
| 157 | else { |
| 158 | txBigInt* bits = fxBigInt_ulsl1(the, C_NULL, (txBigInt *)&gxBigIntOne, index); |
| 159 | txBigInt* mask = fxBigInt_usub(the, C_NULL, bits, (txBigInt *)&gxBigIntOne); |
| 160 | result = fxBigInt_uand(the, C_NULL, arg, mask); |
| 161 | if ((arg->sign) && !fxBigInt_iszero(result)) |
| 162 | result = fxBigInt_usub(the, C_NULL, bits, result); |
| 163 | if (index && fxBigInt_comp(result, fxBigInt_ulsl1(the, C_NULL, (txBigInt *)&gxBigIntOne, index - 1)) >= 0) |
| 164 | result = fxBigInt_sub(the, C_NULL, result, bits); |
| 165 | result = fxBigInt_fit(the, result); |
| 166 | } |
| 167 | mxResult->value.bigint = *result; |
| 168 | mxResult->kind = XS_BIGINT_KIND; |
| 169 | // txBigInt* bits = fxBigInt_ulsl1(the, C_NULL, (txBigInt *)&gxBigIntOne, index); |
| 170 | // txBigInt* result = fxBigInt_mod(the, C_NULL, fxToBigInt(the, mxArgv(1), 1), bits); |
| 171 | // if (index && fxBigInt_comp(result, fxBigInt_ulsl1(the, C_NULL, (txBigInt *)&gxBigIntOne, index - 1)) >= 0) |
| 172 | // result = fxBigInt_sub(the, C_NULL, result, bits); |
| 173 | // mxResult->value.bigint = *result; |
| 174 | // mxResult->kind = XS_BIGINT_KIND; |
| 175 | } |
| 176 | |
| 177 | void fx_BigInt_asUintN(txMachine* the) |
| 178 | { |
nothing calls this directly
no test coverage detected