| 613 | } |
| 614 | |
| 615 | void fx_Math_sumPrecise(txMachine* the) |
| 616 | { |
| 617 | txSlot *iterable, *iterator, *next, *value; |
| 618 | xsum_small_accumulator accumulator; |
| 619 | txInteger count = 0; |
| 620 | txBoolean flag = 1; |
| 621 | if (mxArgc < 1) |
| 622 | mxTypeError("no items"); |
| 623 | iterable = mxArgv(0); |
| 624 | fxToInstance(the, iterable); |
| 625 | mxTemporary(iterator); |
| 626 | mxTemporary(next); |
| 627 | fxGetIterator(the, iterable, iterator, next, 0); |
| 628 | xsum_small_init(&accumulator); |
| 629 | mxTemporary(value); |
| 630 | while (fxIteratorNext(the, iterator, next, value)) { |
| 631 | mxTry(the) { |
| 632 | if (value->kind == XS_INTEGER_KIND) { |
| 633 | flag = 0; |
| 634 | xsum_small_add1(&accumulator, value->value.integer); |
| 635 | } |
| 636 | else if (value->kind == XS_NUMBER_KIND) { |
| 637 | if (value->value.number != -0.0) { |
| 638 | flag = 0; |
| 639 | xsum_small_add1(&accumulator, value->value.number); |
| 640 | } |
| 641 | } |
| 642 | else |
| 643 | mxTypeError("items[%d]: not a number", count); |
| 644 | count++; |
| 645 | } |
| 646 | mxCatch(the) { |
| 647 | fxIteratorReturn(the, iterator, 1); |
| 648 | fxJump(the); |
| 649 | } |
| 650 | } |
| 651 | if (flag) |
| 652 | mxResult->value.number = -0.0; |
| 653 | else |
| 654 | mxResult->value.number = xsum_small_round(&accumulator); |
| 655 | mxResult->kind = XS_NUMBER_KIND; |
| 656 | } |
| 657 | |
| 658 | void fx_Math_sign(txMachine* the) |
| 659 | { |
nothing calls this directly
no test coverage detected