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

Function decNumberLogB

extern/decNumber/decNumber.c:1322–1351  ·  view source on GitHub ↗

------------------------------------------------------------------ */ decNumberLogB - get adjusted exponent, by 754 rules */ / This computes C = adjustedexponent(A) */ / res is C, the result. C may be A */ rhs is A */ set is the context, used only for digits and status

Source from the content-addressed store, hash-verified

1320/* NaNs are propagated as usual */
1321/* ------------------------------------------------------------------ */
1322decNumber * decNumberLogB(decNumber *res, const decNumber *rhs,
1323 decContext *set) {
1324 uInt status=0; // accumulator
1325
1326 #if DECCHECK
1327 if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
1328 #endif
1329
1330 // NaNs as usual; Infinities return +Infinity; 0->oops
1331 if (decNumberIsNaN(rhs)) decNaNs(res, rhs, NULL, set, &status);
1332 else if (decNumberIsInfinite(rhs)) decNumberCopyAbs(res, rhs);
1333 else if (decNumberIsZero(rhs)) {
1334 decNumberZero(res); // prepare for Infinity
1335 res->bits=DECNEG|DECINF; // -Infinity
1336 status|=DEC_Division_by_zero; // as per 754
1337 }
1338 else { // finite non-zero
1339 Int ae=rhs->exponent+rhs->digits-1; // adjusted exponent
1340 if (set->digits>=10) decNumberFromInt32(res, ae); // lay it out
1341 else {
1342 decNumber buft[D2N(10)]; // temporary number
1343 decNumber *t=buft; // ..
1344 decNumberFromInt32(t, ae); // lay it out
1345 decNumberPlus(res, t, set); // round as necessary
1346 }
1347 }
1348
1349 if (status!=0) decStatus(res, status, set);
1350 return res;
1351 } // decNumberLogB
1352
1353/* ------------------------------------------------------------------ */
1354/* decNumberLog10 -- logarithm in base 10 */

Callers

nothing calls this directly

Calls 5

decCheckOperandsFunction · 0.85
decNumberFromInt32Function · 0.85
decNumberPlusFunction · 0.85
decStatusFunction · 0.85
decNaNsFunction · 0.70

Tested by

no test coverage detected