MCPcopy Create free account
hub / github.com/audacity/audacity / decimal_cmp

Function decimal_cmp

lib-src/sqlite/shell.c:4764–4786  ·  view source on GitHub ↗

** Compare to Decimal objects. Return negative, 0, or positive if the ** first object is less than, equal to, or greater than the second. ** ** Preconditions for this routine: ** ** pA!=0 ** pA->isNull==0 ** pB!=0 ** pB->isNull==0 */

Source from the content-addressed store, hash-verified

4762** pB->isNull==0
4763*/
4764static int decimal_cmp(const Decimal *pA, const Decimal *pB){
4765 int nASig, nBSig, rc, n;
4766 if( pA->sign!=pB->sign ){
4767 return pA->sign ? -1 : +1;
4768 }
4769 if( pA->sign ){
4770 const Decimal *pTemp = pA;
4771 pA = pB;
4772 pB = pTemp;
4773 }
4774 nASig = pA->nDigit - pA->nFrac;
4775 nBSig = pB->nDigit - pB->nFrac;
4776 if( nASig!=nBSig ){
4777 return nASig - nBSig;
4778 }
4779 n = pA->nDigit;
4780 if( n>pB->nDigit ) n = pB->nDigit;
4781 rc = memcmp(pA->a, pB->a, n);
4782 if( rc==0 ){
4783 rc = pA->nDigit - pB->nDigit;
4784 }
4785 return rc;
4786}
4787
4788/*
4789** SQL Function: decimal_cmp(X, Y)

Callers 2

decimalCmpFuncFunction · 0.85
decimalCollFuncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected