------------------------------------------------------------------ */ 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
| 1320 | /* NaNs are propagated as usual */ |
| 1321 | /* ------------------------------------------------------------------ */ |
| 1322 | decNumber * 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 */ |
nothing calls this directly
no test coverage detected