MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / decNumberNextPlus

Function decNumberNextPlus

extern/decNumber/decNumber.c:1692–1716  ·  view source on GitHub ↗

------------------------------------------------------------------ */ decNumberNextPlus -- 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

Source from the content-addressed store, hash-verified

1690/* This is a generalization of 754 NextUp. */
1691/* ------------------------------------------------------------------ */
1692decNumber * decNumberNextPlus(decNumber *res, const decNumber *rhs,
1693 decContext *set) {
1694 decNumber dtiny; // constant
1695 decContext workset=*set; // work
1696 uInt status=0; // accumulator
1697 #if DECCHECK
1698 if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
1699 #endif
1700
1701 // -Infinity is the special case
1702 if ((rhs->bits&(DECINF|DECNEG))==(DECINF|DECNEG)) {
1703 decSetMaxValue(res, set);
1704 res->bits=DECNEG; // negative
1705 // there is no status to set
1706 return res;
1707 }
1708 decNumberZero(&dtiny); // start with 0
1709 dtiny.lsu[0]=1; // make number that is ..
1710 dtiny.exponent=DEC_MIN_EMIN-1; // .. smaller than tiniest
1711 workset.round=DEC_ROUND_CEILING;
1712 decAddOp(res, rhs, &dtiny, &workset, 0, &status);
1713 status&=DEC_Invalid_operation|DEC_sNaN; // only sNaN Invalid please
1714 if (status!=0) decStatus(res, status, set);
1715 return res;
1716 } // decNumberNextPlus
1717
1718/* ------------------------------------------------------------------ */
1719/* decNumberNextToward -- next towards rhs */

Callers

nothing calls this directly

Calls 3

decCheckOperandsFunction · 0.85
decSetMaxValueFunction · 0.85
decStatusFunction · 0.85

Tested by

no test coverage detected