------------------------------------------------------------------ */ decNumberAbs -- absolute value operator */ / This computes C = abs(A) */ / res is C, the result. C may be A */ rhs is A */ set is the context
| 725 | /* in which case it has the same effect as decNumberMinus. */ |
| 726 | /* ------------------------------------------------------------------ */ |
| 727 | decNumber * decNumberAbs(decNumber *res, const decNumber *rhs, |
| 728 | decContext *set) { |
| 729 | decNumber dzero; // for 0 |
| 730 | uInt status=0; // accumulator |
| 731 | |
| 732 | #if DECCHECK |
| 733 | if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; |
| 734 | #endif |
| 735 | |
| 736 | decNumberZero(&dzero); // set 0 |
| 737 | dzero.exponent=rhs->exponent; // [no coefficient expansion] |
| 738 | decAddOp(res, &dzero, rhs, set, (uByte)(rhs->bits & DECNEG), &status); |
| 739 | if (status!=0) decStatus(res, status, set); |
| 740 | #if DECCHECK |
| 741 | decCheckInexact(res, set); |
| 742 | #endif |
| 743 | return res; |
| 744 | } // decNumberAbs |
| 745 | |
| 746 | /* ------------------------------------------------------------------ */ |
| 747 | /* decNumberAdd -- add two Numbers */ |
nothing calls this directly
no test coverage detected