| 763 | } |
| 764 | |
| 765 | SINT64 Decimal128::toInt64(DecimalStatus decSt, int scale) const |
| 766 | { |
| 767 | static CDecimal128 quant(1); |
| 768 | |
| 769 | Decimal128 wrk(*this); |
| 770 | wrk.setScale(decSt, -scale); |
| 771 | wrk = wrk.quantize(decSt, quant); |
| 772 | |
| 773 | if (wrk.compare(decSt, i64min) < 0 || wrk.compare(decSt, i64max) > 0) |
| 774 | { |
| 775 | DecimalContext context(this, decSt, true); |
| 776 | decContextSetStatus(&context, DEC_Invalid_operation); |
| 777 | return 0; // in case of no trap on invalid operation |
| 778 | } |
| 779 | |
| 780 | unsigned char coeff[DECQUAD_Pmax]; |
| 781 | int sign = decQuadGetCoefficient(&wrk.dec, coeff); |
| 782 | SINT64 rc = 0; |
| 783 | |
| 784 | for (int i = 0; i < DECQUAD_Pmax; ++i) |
| 785 | { |
| 786 | rc *= 10; |
| 787 | if (sign) |
| 788 | rc -= coeff[i]; |
| 789 | else |
| 790 | rc += coeff[i]; |
| 791 | } |
| 792 | |
| 793 | return rc; |
| 794 | } |
| 795 | |
| 796 | UCHAR* Decimal128::getBytes() |
| 797 | { |
nothing calls this directly
no test coverage detected