------------------------------------------------------------------ */ decNumberNextMinus -- next towards -Infinity */ / This computes C = A - infinitesimal, rounded towards -Infinity */ / res is C, the result. C may be A */ rhs is A */ set is the context
| 1654 | /* This is a generalization of 754 NextDown. */ |
| 1655 | /* ------------------------------------------------------------------ */ |
| 1656 | decNumber * decNumberNextMinus(decNumber *res, const decNumber *rhs, |
| 1657 | decContext *set) { |
| 1658 | decNumber dtiny; // constant |
| 1659 | decContext workset=*set; // work |
| 1660 | uInt status=0; // accumulator |
| 1661 | #if DECCHECK |
| 1662 | if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; |
| 1663 | #endif |
| 1664 | |
| 1665 | // +Infinity is the special case |
| 1666 | if ((rhs->bits&(DECINF|DECNEG))==DECINF) { |
| 1667 | decSetMaxValue(res, set); // is +ve |
| 1668 | // there is no status to set |
| 1669 | return res; |
| 1670 | } |
| 1671 | decNumberZero(&dtiny); // start with 0 |
| 1672 | dtiny.lsu[0]=1; // make number that is .. |
| 1673 | dtiny.exponent=DEC_MIN_EMIN-1; // .. smaller than tiniest |
| 1674 | workset.round=DEC_ROUND_FLOOR; |
| 1675 | decAddOp(res, rhs, &dtiny, &workset, DECNEG, &status); |
| 1676 | status&=DEC_Invalid_operation|DEC_sNaN; // only sNaN Invalid please |
| 1677 | if (status!=0) decStatus(res, status, set); |
| 1678 | return res; |
| 1679 | } // decNumberNextMinus |
| 1680 | |
| 1681 | /* ------------------------------------------------------------------ */ |
| 1682 | /* decNumberNextPlus -- next towards +Infinity */ |
nothing calls this directly
no test coverage detected