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

Function decNumberExp

extern/decNumber/decNumber.c:1036–1074  ·  view source on GitHub ↗

------------------------------------------------------------------ */ decNumberExp -- exponentiation */ / This computes C = exp(A) */ / res is C, the result. C may be A */ rhs is A */ set is the context; note that rounding mode has no e

Source from the content-addressed store, hash-verified

1034/* exp(-a) where a can be the tiniest number (Ntiny). */
1035/* ------------------------------------------------------------------ */
1036decNumber * decNumberExp(decNumber *res, const decNumber *rhs,
1037 decContext *set) {
1038 uInt status=0; // accumulator
1039 #if DECSUBSET
1040 decNumber *allocrhs=NULL; // non-NULL if rounded rhs allocated
1041 #endif
1042
1043 #if DECCHECK
1044 if (decCheckOperands(res, DECUNUSED, rhs, set)) return res;
1045 #endif
1046
1047 // Check restrictions; these restrictions ensure that if h=8 (see
1048 // decExpOp) then the result will either overflow or underflow to 0.
1049 // Other math functions restrict the input range, too, for inverses.
1050 // If not violated then carry out the operation.
1051 if (!decCheckMath(rhs, set, &status)) do { // protect allocation
1052 #if DECSUBSET
1053 if (!set->extended) {
1054 // reduce operand and set lostDigits status, as needed
1055 if (rhs->digits>set->digits) {
1056 allocrhs=decRoundOperand(rhs, set, &status);
1057 if (allocrhs==NULL) break;
1058 rhs=allocrhs;
1059 }
1060 }
1061 #endif
1062 decExpOp(res, rhs, set, &status);
1063 } while(0); // end protected
1064
1065 #if DECSUBSET
1066 if (allocrhs !=NULL) free(allocrhs); // drop any storage used
1067 #endif
1068 // apply significant status
1069 if (status!=0) decStatus(res, status, set);
1070 #if DECCHECK
1071 decCheckInexact(res, set);
1072 #endif
1073 return res;
1074 } // decNumberExp
1075
1076/* ------------------------------------------------------------------ */
1077/* decNumberFMA -- fused multiply add */

Callers

nothing calls this directly

Calls 6

decCheckOperandsFunction · 0.85
decCheckMathFunction · 0.85
decRoundOperandFunction · 0.85
decExpOpFunction · 0.85
decStatusFunction · 0.85
decCheckInexactFunction · 0.85

Tested by

no test coverage detected