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

Function decNumberShow

extern/decNumber/decNumber.c:7811–7853  ·  view source on GitHub ↗

------------------------------------------------------------------ */ decNumberShow -- display a number [debug aid] */ dn is the number to show */ / Shows: sign, exponent, coefficient (msu first), digits */ or: sign, special-value */ -----------------------------------------------------

Source from the content-addressed store, hash-verified

7809/* ------------------------------------------------------------------ */
7810// this is public so other modules can use it
7811void decNumberShow(const decNumber *dn) {
7812 const Unit *up; // work
7813 uInt u, d; // ..
7814 Int cut; // ..
7815 char isign='+'; // main sign
7816 if (dn==NULL) {
7817 printf("NULL\n");
7818 return;}
7819 if (decNumberIsNegative(dn)) isign='-';
7820 printf(" >> %c ", isign);
7821 if (dn->bits&DECSPECIAL) { // Is a special value
7822 if (decNumberIsInfinite(dn)) printf("Infinity");
7823 else { // a NaN
7824 if (dn->bits&DECSNAN) printf("sNaN"); // signalling NaN
7825 else printf("NaN");
7826 }
7827 // if coefficient and exponent are 0, no more to do
7828 if (dn->exponent==0 && dn->digits==1 && *dn->lsu==0) {
7829 printf("\n");
7830 return;}
7831 // drop through to report other information
7832 printf(" ");
7833 }
7834
7835 // now carefully display the coefficient
7836 up=dn->lsu+D2U(dn->digits)-1; // msu
7837 printf("%ld", (LI)*up);
7838 for (up=up-1; up>=dn->lsu; up--) {
7839 u=*up;
7840 printf(":");
7841 for (cut=DECDPUN-1; cut>=0; cut--) {
7842 d=u/powers[cut];
7843 u-=d*powers[cut];
7844 printf("%ld", (LI)d);
7845 } // cut
7846 } // up
7847 if (dn->exponent!=0) {
7848 char esign='+';
7849 if (dn->exponent<0) esign='-';
7850 printf(" E%c%ld", esign, (LI)abs(dn->exponent));
7851 }
7852 printf(" [%ld]\n", (LI)dn->digits);
7853 } // decNumberShow
7854#endif
7855
7856#if DECTRACE || DECCHECK

Callers 2

decCheckNumberFunction · 0.85
decCheckInexactFunction · 0.85

Calls 1

absFunction · 0.85

Tested by

no test coverage detected