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

Function decRoundOperand

extern/decNumber/decNumber.c:6805–6826  ·  view source on GitHub ↗

------------------------------------------------------------------ */ decRoundOperand -- round an operand [used for subset only] */ / dn is the number to round (dn->digits is > set->digits) */ set is the relevant context */ status is the status accumulator */ / returns an allocated decNumber with the rounded resu

Source from the content-addressed store, hash-verified

6803/* is returned. */
6804/* ------------------------------------------------------------------ */
6805static decNumber *decRoundOperand(const decNumber *dn, decContext *set,
6806 uInt *status) {
6807 decNumber *res; // result structure
6808 uInt newstatus=0; // status from round
6809 Int residue=0; // rounding accumulator
6810
6811 // Allocate storage for the returned decNumber, big enough for the
6812 // length specified by the context
6813 res=(decNumber *)malloc(sizeof(decNumber)
6814 +(D2U(set->digits)-1)*sizeof(Unit));
6815 if (res==NULL) {
6816 *status|=DEC_Insufficient_storage;
6817 return NULL;
6818 }
6819 decCopyFit(res, dn, set, &residue, &newstatus);
6820 decApplyRound(res, set, residue, &newstatus);
6821
6822 // If that set Inexact then "lost digits" is raised...
6823 if (newstatus & DEC_Inexact) newstatus|=DEC_Lost_digits;
6824 *status|=newstatus;
6825 return res;
6826 } // decRoundOperand
6827#endif
6828
6829/* ------------------------------------------------------------------ */

Callers 6

decNumberExpFunction · 0.85
decNumberLnFunction · 0.85
decNumberLog10Function · 0.85
decNumber.cFile · 0.85
decQuantizeOpFunction · 0.85
decCompareOpFunction · 0.85

Calls 2

decCopyFitFunction · 0.85
decApplyRoundFunction · 0.85

Tested by

no test coverage detected