diff options
author | Ben Elliston <bje@au.ibm.com> | 2009-03-30 02:29:05 +0000 |
---|---|---|
committer | Ben Elliston <bje@gcc.gnu.org> | 2009-03-30 13:29:05 +1100 |
commit | 7bd36a9ce8182902f45b30657871bb0718186562 (patch) | |
tree | d96581fe4613004a7be64f917dc24d8bca6a8e68 /libdecnumber/dpd | |
parent | a9a7a9a2498c257114058e94aded2c89cf913c6e (diff) | |
download | gcc-7bd36a9ce8182902f45b30657871bb0718186562.zip gcc-7bd36a9ce8182902f45b30657871bb0718186562.tar.gz gcc-7bd36a9ce8182902f45b30657871bb0718186562.tar.bz2 |
Merge botch fixed.
* decNumber.c, decNumber.h, decNumberLocal.h, decDouble.c,
decDouble.h, decSingle.c, decContext.c, decSingle.h, decPacked.c,
decCommon.c, decContext.h, decQuad.c, decPacked.h, decQuad.h,
decDPD.h, decBasic.c: Upgrade to decNumber 3.61.
* dpd/decimal128.h, dpd/decimal32.c, dpd/decimal32.h,
dpd/decimal64.c, dpd/decimal128.c, dpd/decimal64.h: Likewise.
From-SVN: r145274
Diffstat (limited to 'libdecnumber/dpd')
-rw-r--r-- | libdecnumber/dpd/decimal128.c | 119 | ||||
-rw-r--r-- | libdecnumber/dpd/decimal128.h | 16 | ||||
-rw-r--r-- | libdecnumber/dpd/decimal32.c | 83 | ||||
-rw-r--r-- | libdecnumber/dpd/decimal32.h | 14 | ||||
-rw-r--r-- | libdecnumber/dpd/decimal64.c | 133 | ||||
-rw-r--r-- | libdecnumber/dpd/decimal64.h | 14 |
6 files changed, 187 insertions, 192 deletions
diff --git a/libdecnumber/dpd/decimal128.c b/libdecnumber/dpd/decimal128.c index 54191aa..edf22e1 100644 --- a/libdecnumber/dpd/decimal128.c +++ b/libdecnumber/dpd/decimal128.c @@ -42,11 +42,11 @@ #include <string.h> /* [for memset/memcpy] */ #include <stdio.h> /* [for printf] */ -#include "dconfig.h" /* GCC definitions */ -#define DECNUMDIGITS 34 /* make decNumbers with space for 34 */ +#include "dconfig.h" /* GCC definitions */ +#define DECNUMDIGITS 34 /* make decNumbers with space for 34 */ #include "decNumber.h" /* base number library */ #include "decNumberLocal.h" /* decNumber local types, etc. */ -#include "decimal128.h" /* our primary include */ +#include "decimal128.h" /* our primary include */ /* Utility routines and tables [in decimal64.c] */ extern const uInt COMBEXP[32], COMBMSD[32]; @@ -71,7 +71,7 @@ extern void decNumberShow(const decNumber *); /* .. */ /* */ /* ds is the target decimal128 */ /* dn is the source number (assumed valid) */ -/* set is the context, used only for reporting errors */ +/* set is the context, used only for reporting errors */ /* */ /* The set argument is used only for status reporting and for the */ /* rounding mode (used if the coefficient is more than DECIMAL128_Pmax*/ @@ -89,8 +89,8 @@ decimal128 * decimal128FromNumber(decimal128 *d128, const decNumber *dn, Int ae; /* adjusted exponent */ decNumber dw; /* work */ decContext dc; /* .. */ - uInt *pu; /* .. */ uInt comb, exp; /* .. */ + uInt uiwork; /* for macros */ uInt targar[4]={0,0,0,0}; /* target 128-bit */ #define targhi targar[3] /* name the word with the sign */ #define targmh targar[2] /* name the words */ @@ -102,7 +102,7 @@ decimal128 * decimal128FromNumber(decimal128 *d128, const decNumber *dn, /* constraints. This could push the number to Infinity or zero, */ /* so this check and rounding must be done before generating the */ /* decimal128] */ - ae=dn->exponent+dn->digits-1; /* [0 if special] */ + ae=dn->exponent+dn->digits-1; /* [0 if special] */ if (dn->digits>DECIMAL128_Pmax /* too many digits */ || ae>DECIMAL128_Emax /* likely overflow */ || ae<DECIMAL128_Emin) { /* likely underflow */ @@ -118,7 +118,7 @@ decimal128 * decimal128FromNumber(decimal128 *d128, const decNumber *dn, if (dn->bits&DECSPECIAL) { /* a special value */ if (dn->bits&DECINF) targhi=DECIMAL_Inf<<24; else { /* sNaN or qNaN */ - if ((*dn->lsu!=0 || dn->digits>1) /* non-zero coefficient */ + if ((*dn->lsu!=0 || dn->digits>1) /* non-zero coefficient */ && (dn->digits<DECIMAL128_Pmax)) { /* coefficient fits */ decDigitsToDPD(dn, targar, 0); } @@ -144,11 +144,11 @@ decimal128 * decimal128FromNumber(decimal128 *d128, const decNumber *dn, comb=(exp>>9) & 0x18; /* msd=0, exp top 2 bits .. */ } else { /* non-zero finite number */ - uInt msd; /* work */ + uInt msd; /* work */ Int pad=0; /* coefficient pad digits */ /* the dn is known to fit, but it may need to be padded */ - exp=(uInt)(dn->exponent+DECIMAL128_Bias); /* bias exponent */ + exp=(uInt)(dn->exponent+DECIMAL128_Bias); /* bias exponent */ if (exp>DECIMAL128_Ehigh) { /* fold-down case */ pad=exp-DECIMAL128_Ehigh; exp=DECIMAL128_Ehigh; /* [to maximum] */ @@ -172,18 +172,19 @@ decimal128 * decimal128FromNumber(decimal128 *d128, const decNumber *dn, if (dn->bits&DECNEG) targhi|=0x80000000; /* add sign bit */ /* now write to storage; this is endian */ - pu=(uInt *)d128->bytes; /* overlay */ if (DECLITEND) { - pu[0]=targlo; /* directly store the low int */ - pu[1]=targml; /* then the mid-low */ - pu[2]=targmh; /* then the mid-high */ - pu[3]=targhi; /* then the high int */ + /* lo -> hi */ + UBFROMUI(d128->bytes, targlo); + UBFROMUI(d128->bytes+4, targml); + UBFROMUI(d128->bytes+8, targmh); + UBFROMUI(d128->bytes+12, targhi); } else { - pu[0]=targhi; /* directly store the high int */ - pu[1]=targmh; /* then the mid-high */ - pu[2]=targml; /* then the mid-low */ - pu[3]=targlo; /* then the low int */ + /* hi -> lo */ + UBFROMUI(d128->bytes, targhi); + UBFROMUI(d128->bytes+4, targmh); + UBFROMUI(d128->bytes+8, targml); + UBFROMUI(d128->bytes+12, targlo); } if (status!=0) decContextSetStatus(set, status); /* pass on status */ @@ -201,8 +202,8 @@ decNumber * decimal128ToNumber(const decimal128 *d128, decNumber *dn) { uInt msd; /* coefficient MSD */ uInt exp; /* exponent top two bits */ uInt comb; /* combination field */ - const uInt *pu; /* work */ - Int need; /* .. */ + Int need; /* work */ + uInt uiwork; /* for macros */ uInt sourar[4]; /* source 128-bit */ #define sourhi sourar[3] /* name the word with the sign */ #define sourmh sourar[2] /* and the mid-high word */ @@ -210,18 +211,17 @@ decNumber * decimal128ToNumber(const decimal128 *d128, decNumber *dn) { #define sourlo sourar[0] /* and the lowest word */ /* load source from storage; this is endian */ - pu=(const uInt *)d128->bytes; /* overlay */ if (DECLITEND) { - sourlo=pu[0]; /* directly load the low int */ - sourml=pu[1]; /* then the mid-low */ - sourmh=pu[2]; /* then the mid-high */ - sourhi=pu[3]; /* then the high int */ + sourlo=UBTOUI(d128->bytes ); /* directly load the low int */ + sourml=UBTOUI(d128->bytes+4 ); /* then the mid-low */ + sourmh=UBTOUI(d128->bytes+8 ); /* then the mid-high */ + sourhi=UBTOUI(d128->bytes+12); /* then the high int */ } else { - sourhi=pu[0]; /* directly load the high int */ - sourmh=pu[1]; /* then the mid-high */ - sourml=pu[2]; /* then the mid-low */ - sourlo=pu[3]; /* then the low int */ + sourhi=UBTOUI(d128->bytes ); /* directly load the high int */ + sourmh=UBTOUI(d128->bytes+4 ); /* then the mid-high */ + sourml=UBTOUI(d128->bytes+8 ); /* then the mid-low */ + sourlo=UBTOUI(d128->bytes+12); /* then the low int */ } comb=(sourhi>>26)&0x1f; /* combination field */ @@ -232,7 +232,7 @@ decNumber * decimal128ToNumber(const decimal128 *d128, decNumber *dn) { msd=COMBMSD[comb]; /* decode the combination field */ exp=COMBEXP[comb]; /* .. */ - if (exp==3) { /* is a special */ + if (exp==3) { /* is a special */ if (msd==0) { dn->bits|=DECINF; return dn; /* no coefficient needed */ @@ -265,7 +265,7 @@ decNumber * decimal128ToNumber(const decimal128 *d128, decNumber *dn) { } /* decimal128ToNumber */ /* ------------------------------------------------------------------ */ -/* to-scientific-string -- conversion to numeric string */ +/* to-scientific-string -- conversion to numeric string */ /* to-engineering-string -- conversion to numeric string */ /* */ /* decimal128ToString(d128, string); */ @@ -279,7 +279,7 @@ decNumber * decimal128ToNumber(const decimal128 *d128, decNumber *dn) { /* No error is possible, and no status can be set. */ /* ------------------------------------------------------------------ */ char * decimal128ToEngString(const decimal128 *d128, char *string){ - decNumber dn; /* work */ + decNumber dn; /* work */ decimal128ToNumber(d128, &dn); decNumberToEngString(&dn, string); return string; @@ -289,13 +289,13 @@ char * decimal128ToString(const decimal128 *d128, char *string){ uInt msd; /* coefficient MSD */ Int exp; /* exponent top two bits or full */ uInt comb; /* combination field */ - char *cstart; /* coefficient start */ + char *cstart; /* coefficient start */ char *c; /* output pointer in string */ - const uInt *pu; /* work */ + const uByte *u; /* work */ char *s, *t; /* .. (source, target) */ Int dpd; /* .. */ Int pre, e; /* .. */ - const uByte *u; /* .. */ + uInt uiwork; /* for macros */ uInt sourar[4]; /* source 128-bit */ #define sourhi sourar[3] /* name the word with the sign */ @@ -304,18 +304,17 @@ char * decimal128ToString(const decimal128 *d128, char *string){ #define sourlo sourar[0] /* and the lowest word */ /* load source from storage; this is endian */ - pu=(const uInt *)d128->bytes; /* overlay */ if (DECLITEND) { - sourlo=pu[0]; /* directly load the low int */ - sourml=pu[1]; /* then the mid-low */ - sourmh=pu[2]; /* then the mid-high */ - sourhi=pu[3]; /* then the high int */ + sourlo=UBTOUI(d128->bytes ); /* directly load the low int */ + sourml=UBTOUI(d128->bytes+4 ); /* then the mid-low */ + sourmh=UBTOUI(d128->bytes+8 ); /* then the mid-high */ + sourhi=UBTOUI(d128->bytes+12); /* then the high int */ } else { - sourhi=pu[0]; /* directly load the high int */ - sourmh=pu[1]; /* then the mid-high */ - sourml=pu[2]; /* then the mid-low */ - sourlo=pu[3]; /* then the low int */ + sourhi=UBTOUI(d128->bytes ); /* directly load the high int */ + sourmh=UBTOUI(d128->bytes+4 ); /* then the mid-high */ + sourml=UBTOUI(d128->bytes+8 ); /* then the mid-low */ + sourlo=UBTOUI(d128->bytes+12); /* then the low int */ } c=string; /* where result will go */ @@ -327,7 +326,7 @@ char * decimal128ToString(const decimal128 *d128, char *string){ if (exp==3) { if (msd==0) { /* infinity */ - strcpy(c, "Inf"); + strcpy(c, "Inf"); strcpy(c+3, "inity"); return string; /* easy */ } @@ -353,12 +352,12 @@ char * decimal128ToString(const decimal128 *d128, char *string){ /* length. We use fixed-length memcpys because variable-length */ /* causes a subroutine call in GCC. (These are length 4 for speed */ /* and are safe because the array has an extra terminator byte.) */ - #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \ + #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \ if (c!=cstart) {memcpy(c, u+1, 4); c+=3;} \ else if (*u) {memcpy(c, u+4-*u, 4); c+=*u;} dpd=(sourhi>>4)&0x3ff; /* declet 1 */ dpd2char; - dpd=((sourhi&0xf)<<6) | (sourmh>>26); /* declet 2 */ + dpd=((sourhi&0xf)<<6) | (sourmh>>26); /* declet 2 */ dpd2char; dpd=(sourmh>>16)&0x3ff; /* declet 3 */ dpd2char; @@ -381,7 +380,7 @@ char * decimal128ToString(const decimal128 *d128, char *string){ if (c==cstart) *c++='0'; /* all zeros -- make 0 */ - if (exp==0) { /* integer or NaN case -- easy */ + if (exp==0) { /* integer or NaN case -- easy */ *c='\0'; /* terminate */ return string; } @@ -409,8 +408,8 @@ char * decimal128ToString(const decimal128 *d128, char *string){ /* finally add the E-part, if needed; it will never be 0, and has */ /* a maximum length of 4 digits */ if (e!=0) { - *c++='E'; /* starts with E */ - *c++='+'; /* assume positive */ + *c++='E'; /* starts with E */ + *c++='+'; /* assume positive */ if (e<0) { *(c-1)='-'; /* oops, need '-' */ e=-e; /* uInt, please */ @@ -449,13 +448,13 @@ char * decimal128ToString(const decimal128 *d128, char *string){ /* ------------------------------------------------------------------ */ /* to-number -- conversion from numeric string */ /* */ -/* decimal128FromString(result, string, set); */ +/* decimal128FromString(result, string, set); */ /* */ /* result is the decimal128 format number which gets the result of */ /* the conversion */ /* *string is the character string which should contain a valid */ /* number (which may be a special value) */ -/* set is the context */ +/* set is the context */ /* */ /* The context is supplied to this routine is used for error handling */ /* (setting of status and traps) and for the rounding mode, only. */ @@ -464,7 +463,7 @@ char * decimal128ToString(const decimal128 *d128, char *string){ decimal128 * decimal128FromString(decimal128 *result, const char *string, decContext *set) { decContext dc; /* work */ - decNumber dn; /* .. */ + decNumber dn; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL128); /* no traps, please */ dc.round=set->round; /* use supplied rounding */ @@ -483,8 +482,8 @@ decimal128 * decimal128FromString(decimal128 *result, const char *string, /* returns 1 if the encoding of d128 is canonical, 0 otherwise */ /* No error is possible. */ /* ------------------------------------------------------------------ */ -uint32_t decimal128IsCanonical(const decimal128 *d128) { - decNumber dn; /* work */ +uInt decimal128IsCanonical(const decimal128 *d128) { + decNumber dn; /* work */ decimal128 canon; /* .. */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL128); @@ -501,7 +500,7 @@ uint32_t decimal128IsCanonical(const decimal128 *d128) { /* No error is possible. */ /* ------------------------------------------------------------------ */ decimal128 * decimal128Canonical(decimal128 *result, const decimal128 *d128) { - decNumber dn; /* work */ + decNumber dn; /* work */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL128); decimal128ToNumber(d128, &dn); @@ -532,13 +531,13 @@ decimal128 * decimal128Canonical(decimal128 *result, const decimal128 *d128) { /* This assumes range has been checked and exponent previously 0; */ /* type of exponent must be unsigned */ #define decimal128SetExpCon(d, e) { \ - (d)->bytes[0]|=(uint8_t)((e)>>10); \ - (d)->bytes[1] =(uint8_t)(((e)&0x3fc)>>2); \ - (d)->bytes[2]|=(uint8_t)(((e)&0x03)<<6);} + (d)->bytes[0]|=(uByte)((e)>>10); \ + (d)->bytes[1] =(uByte)(((e)&0x3fc)>>2); \ + (d)->bytes[2]|=(uByte)(((e)&0x03)<<6);} /* ------------------------------------------------------------------ */ /* decimal128Show -- display a decimal128 in hexadecimal [debug aid] */ -/* d128 -- the number to show */ +/* d128 -- the number to show */ /* ------------------------------------------------------------------ */ /* Also shows sign/cob/expconfields extracted */ void decimal128Show(const decimal128 *d128) { diff --git a/libdecnumber/dpd/decimal128.h b/libdecnumber/dpd/decimal128.h index f8f5b5a..95f73f4 100644 --- a/libdecnumber/dpd/decimal128.h +++ b/libdecnumber/dpd/decimal128.h @@ -29,7 +29,7 @@ 02110-1301, USA. */ /* ------------------------------------------------------------------ */ -/* Decimal 128-bit format module header */ +/* Decimal 128-bit format module header */ /* ------------------------------------------------------------------ */ #if !defined(DECIMAL128) @@ -46,7 +46,7 @@ #define DECIMAL128_Bias 6176 /* bias for the exponent */ #define DECIMAL128_String 43 /* maximum string length, +1 */ #define DECIMAL128_EconL 12 /* exp. continuation length */ - /* highest biased exponent (Elimit-1) */ + /* highest biased exponent (Elimit-1) */ #define DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1) /* check enough digits, if pre-defined */ @@ -71,20 +71,20 @@ /* special values [top byte excluding sign bit; last two bits are */ /* don't-care for Infinity on input, last bit don't-care for NaN] */ #if !defined(DECIMAL_NaN) - #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ + #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ - #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ + #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ #endif - #include "decimal128Local.h" +#include "decimal128Local.h" /* ---------------------------------------------------------------- */ /* Routines */ /* ---------------------------------------------------------------- */ - #include "decimal128Symbols.h" +#include "decimal128Symbols.h" - /* String conversions */ + /* String conversions */ decimal128 * decimal128FromString(decimal128 *, const char *, decContext *); char * decimal128ToString(const decimal128 *, char *); char * decimal128ToEngString(const decimal128 *, char *); @@ -94,7 +94,7 @@ decContext *); decNumber * decimal128ToNumber(const decimal128 *, decNumber *); - /* Format-dependent utilities */ + /* Format-dependent utilities */ uint32_t decimal128IsCanonical(const decimal128 *); decimal128 * decimal128Canonical(decimal128 *, const decimal128 *); diff --git a/libdecnumber/dpd/decimal32.c b/libdecnumber/dpd/decimal32.c index d8e3f59..eefd71c 100644 --- a/libdecnumber/dpd/decimal32.c +++ b/libdecnumber/dpd/decimal32.c @@ -29,7 +29,7 @@ 02110-1301, USA. */ /* ------------------------------------------------------------------ */ -/* Decimal 32-bit format module */ +/* Decimal 32-bit format module */ /* ------------------------------------------------------------------ */ /* This module comprises the routines for decimal32 format numbers. */ /* Conversions are supplied to and from decNumber and String. */ @@ -42,8 +42,8 @@ #include <string.h> /* [for memset/memcpy] */ #include <stdio.h> /* [for printf] */ -#include "dconfig.h" /* GCC definitions */ -#define DECNUMDIGITS 7 /* make decNumbers with space for 7 */ +#include "dconfig.h" /* GCC definitions */ +#define DECNUMDIGITS 7 /* make decNumbers with space for 7 */ #include "decNumber.h" /* base number library */ #include "decNumberLocal.h" /* decNumber local types, etc. */ #include "decimal32.h" /* our primary include */ @@ -69,9 +69,9 @@ extern void decNumberShow(const decNumber *); /* .. */ /* ------------------------------------------------------------------ */ /* decimal32FromNumber -- convert decNumber to decimal32 */ /* */ -/* ds is the target decimal32 */ +/* ds is the target decimal32 */ /* dn is the source number (assumed valid) */ -/* set is the context, used only for reporting errors */ +/* set is the context, used only for reporting errors */ /* */ /* The set argument is used only for status reporting and for the */ /* rounding mode (used if the coefficient is more than DECIMAL32_Pmax */ @@ -89,8 +89,8 @@ decimal32 * decimal32FromNumber(decimal32 *d32, const decNumber *dn, Int ae; /* adjusted exponent */ decNumber dw; /* work */ decContext dc; /* .. */ - uInt *pu; /* .. */ uInt comb, exp; /* .. */ + uInt uiwork; /* for macros */ uInt targ=0; /* target 32-bit */ /* If the number has too many digits, or the exponent could be */ @@ -98,9 +98,9 @@ decimal32 * decimal32FromNumber(decimal32 *d32, const decNumber *dn, /* constraints. This could push the number to Infinity or zero, */ /* so this check and rounding must be done before generating the */ /* decimal32] */ - ae=dn->exponent+dn->digits-1; /* [0 if special] */ - if (dn->digits>DECIMAL32_Pmax /* too many digits */ - || ae>DECIMAL32_Emax /* likely overflow */ + ae=dn->exponent+dn->digits-1; /* [0 if special] */ + if (dn->digits>DECIMAL32_Pmax /* too many digits */ + || ae>DECIMAL32_Emax /* likely overflow */ || ae<DECIMAL32_Emin) { /* likely underflow */ decContextDefault(&dc, DEC_INIT_DECIMAL32); /* [no traps] */ dc.round=set->round; /* use supplied rounding */ @@ -114,7 +114,7 @@ decimal32 * decimal32FromNumber(decimal32 *d32, const decNumber *dn, if (dn->bits&DECSPECIAL) { /* a special value */ if (dn->bits&DECINF) targ=DECIMAL_Inf<<24; else { /* sNaN or qNaN */ - if ((*dn->lsu!=0 || dn->digits>1) /* non-zero coefficient */ + if ((*dn->lsu!=0 || dn->digits>1) /* non-zero coefficient */ && (dn->digits<DECIMAL32_Pmax)) { /* coefficient fits */ decDigitsToDPD(dn, &targ, 0); } @@ -140,7 +140,7 @@ decimal32 * decimal32FromNumber(decimal32 *d32, const decNumber *dn, comb=(exp>>3) & 0x18; /* msd=0, exp top 2 bits .. */ } else { /* non-zero finite number */ - uInt msd; /* work */ + uInt msd; /* work */ Int pad=0; /* coefficient pad digits */ /* the dn is known to fit, but it may need to be padded */ @@ -175,8 +175,7 @@ decimal32 * decimal32FromNumber(decimal32 *d32, const decNumber *dn, if (dn->bits&DECNEG) targ|=0x80000000; /* add sign bit */ /* now write to storage; this is endian */ - pu=(uInt *)d32->bytes; /* overlay */ - *pu=targ; /* directly store the int */ + UBFROMUI(d32->bytes, targ); /* directly store the int */ if (status!=0) decContextSetStatus(set, status); /* pass on status */ /* decimal32Show(d32); */ @@ -194,13 +193,12 @@ decNumber * decimal32ToNumber(const decimal32 *d32, decNumber *dn) { uInt exp; /* exponent top two bits */ uInt comb; /* combination field */ uInt sour; /* source 32-bit */ - const uInt *pu; /* work */ + uInt uiwork; /* for macros */ /* load source from storage; this is endian */ - pu=(const uInt *)d32->bytes; /* overlay */ - sour=*pu; /* directly load the int */ + sour=UBTOUI(d32->bytes); /* directly load the int */ - comb=(sour>>26)&0x1f; /* combination field */ + comb=(sour>>26)&0x1f; /* combination field */ decNumberZero(dn); /* clean number */ if (sour&0x80000000) dn->bits=DECNEG; /* set sign if negative */ @@ -208,7 +206,7 @@ decNumber * decimal32ToNumber(const decimal32 *d32, decNumber *dn) { msd=COMBMSD[comb]; /* decode the combination field */ exp=COMBEXP[comb]; /* .. */ - if (exp==3) { /* is a special */ + if (exp==3) { /* is a special */ if (msd==0) { dn->bits|=DECINF; return dn; /* no coefficient needed */ @@ -229,7 +227,7 @@ decNumber * decimal32ToNumber(const decimal32 *d32, decNumber *dn) { return dn; } /* msd=0 */ - if (!sour) return dn; /* easy: coefficient is 0 */ + if (!sour) return dn; /* easy: coefficient is 0 */ if (sour&0x000ffc00) /* need 2 declets? */ decDigitsFromDPD(dn, &sour, 2); /* process 2 declets */ else @@ -238,11 +236,11 @@ decNumber * decimal32ToNumber(const decimal32 *d32, decNumber *dn) { } /* decimal32ToNumber */ /* ------------------------------------------------------------------ */ -/* to-scientific-string -- conversion to numeric string */ +/* to-scientific-string -- conversion to numeric string */ /* to-engineering-string -- conversion to numeric string */ /* */ /* decimal32ToString(d32, string); */ -/* decimal32ToEngString(d32, string); */ +/* decimal32ToEngString(d32, string); */ /* */ /* d32 is the decimal32 format number to convert */ /* string is the string where the result will be laid out */ @@ -252,7 +250,7 @@ decNumber * decimal32ToNumber(const decimal32 *d32, decNumber *dn) { /* No error is possible, and no status can be set. */ /* ------------------------------------------------------------------ */ char * decimal32ToEngString(const decimal32 *d32, char *string){ - decNumber dn; /* work */ + decNumber dn; /* work */ decimal32ToNumber(d32, &dn); decNumberToEngString(&dn, string); return string; @@ -262,29 +260,28 @@ char * decimal32ToString(const decimal32 *d32, char *string){ uInt msd; /* coefficient MSD */ Int exp; /* exponent top two bits or full */ uInt comb; /* combination field */ - char *cstart; /* coefficient start */ + char *cstart; /* coefficient start */ char *c; /* output pointer in string */ - const uInt *pu; /* work */ - const uByte *u; /* .. */ + const uByte *u; /* work */ char *s, *t; /* .. (source, target) */ Int dpd; /* .. */ Int pre, e; /* .. */ + uInt uiwork; /* for macros */ uInt sour; /* source 32-bit */ /* load source from storage; this is endian */ - pu=(const uInt *)d32->bytes; /* overlay */ - sour=*pu; /* directly load the int */ + sour=UBTOUI(d32->bytes); /* directly load the int */ c=string; /* where result will go */ if (((Int)sour)<0) *c++='-'; /* handle sign */ - comb=(sour>>26)&0x1f; /* combination field */ + comb=(sour>>26)&0x1f; /* combination field */ msd=COMBMSD[comb]; /* decode the combination field */ exp=COMBEXP[comb]; /* .. */ if (exp==3) { if (msd==0) { /* infinity */ - strcpy(c, "Inf"); + strcpy(c, "Inf"); strcpy(c+3, "inity"); return string; /* easy */ } @@ -309,18 +306,18 @@ char * decimal32ToString(const decimal32 *d32, char *string){ /* length. We use fixed-length memcpys because variable-length */ /* causes a subroutine call in GCC. (These are length 4 for speed */ /* and are safe because the array has an extra terminator byte.) */ - #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \ + #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \ if (c!=cstart) {memcpy(c, u+1, 4); c+=3;} \ else if (*u) {memcpy(c, u+4-*u, 4); c+=*u;} - dpd=(sour>>10)&0x3ff; /* declet 1 */ + dpd=(sour>>10)&0x3ff; /* declet 1 */ dpd2char; dpd=(sour)&0x3ff; /* declet 2 */ dpd2char; if (c==cstart) *c++='0'; /* all zeros -- make 0 */ - if (exp==0) { /* integer or NaN case -- easy */ + if (exp==0) { /* integer or NaN case -- easy */ *c='\0'; /* terminate */ return string; } @@ -348,13 +345,13 @@ char * decimal32ToString(const decimal32 *d32, char *string){ /* finally add the E-part, if needed; it will never be 0, and has */ /* a maximum length of 3 digits (E-101 case) */ if (e!=0) { - *c++='E'; /* starts with E */ - *c++='+'; /* assume positive */ + *c++='E'; /* starts with E */ + *c++='+'; /* assume positive */ if (e<0) { *(c-1)='-'; /* oops, need '-' */ e=-e; /* uInt, please */ } - u=&BIN2CHAR[e*4]; /* -> length byte */ + u=&BIN2CHAR[e*4]; /* -> length byte */ memcpy(c, u+4-*u, 4); /* copy fixed 4 characters [is safe] */ c+=*u; /* bump pointer appropriately */ } @@ -384,7 +381,7 @@ char * decimal32ToString(const decimal32 *d32, char *string){ /* the conversion */ /* *string is the character string which should contain a valid */ /* number (which may be a special value) */ -/* set is the context */ +/* set is the context */ /* */ /* The context is supplied to this routine is used for error handling */ /* (setting of status and traps) and for the rounding mode, only. */ @@ -393,7 +390,7 @@ char * decimal32ToString(const decimal32 *d32, char *string){ decimal32 * decimal32FromString(decimal32 *result, const char *string, decContext *set) { decContext dc; /* work */ - decNumber dn; /* .. */ + decNumber dn; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL32); /* no traps, please */ dc.round=set->round; /* use supplied rounding */ @@ -409,11 +406,11 @@ decimal32 * decimal32FromString(decimal32 *result, const char *string, /* ------------------------------------------------------------------ */ /* decimal32IsCanonical -- test whether encoding is canonical */ /* d32 is the source decimal32 */ -/* returns 1 if the encoding of d32 is canonical, 0 otherwise */ +/* returns 1 if the encoding of d32 is canonical, 0 otherwise */ /* No error is possible. */ /* ------------------------------------------------------------------ */ -uint32_t decimal32IsCanonical(const decimal32 *d32) { - decNumber dn; /* work */ +uInt decimal32IsCanonical(const decimal32 *d32) { + decNumber dn; /* work */ decimal32 canon; /* .. */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL32); @@ -430,7 +427,7 @@ uint32_t decimal32IsCanonical(const decimal32 *d32) { /* No error is possible. */ /* ------------------------------------------------------------------ */ decimal32 * decimal32Canonical(decimal32 *result, const decimal32 *d32) { - decNumber dn; /* work */ + decNumber dn; /* work */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL32); decimal32ToNumber(d32, &dn); @@ -460,8 +457,8 @@ decimal32 * decimal32Canonical(decimal32 *result, const decimal32 *d32) { /* This assumes range has been checked and exponent previously 0; */ /* type of exponent must be unsigned */ #define decimal32SetExpCon(d, e) { \ - (d)->bytes[0]|=(uint8_t)((e)>>4); \ - (d)->bytes[1]|=(uint8_t)(((e)&0x0F)<<4);} + (d)->bytes[0]|=(uByte)((e)>>4); \ + (d)->bytes[1]|=(uByte)(((e)&0x0F)<<4);} /* ------------------------------------------------------------------ */ /* decimal32Show -- display a decimal32 in hexadecimal [debug aid] */ diff --git a/libdecnumber/dpd/decimal32.h b/libdecnumber/dpd/decimal32.h index 0d53046..222ba97 100644 --- a/libdecnumber/dpd/decimal32.h +++ b/libdecnumber/dpd/decimal32.h @@ -35,7 +35,7 @@ #if !defined(DECIMAL32) #define DECIMAL32 #define DEC32NAME "decimal32" /* Short name */ - #define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */ + #define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */ #define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */ /* parameters for decimal32s */ @@ -46,7 +46,7 @@ #define DECIMAL32_Bias 101 /* bias for the exponent */ #define DECIMAL32_String 15 /* maximum string length, +1 */ #define DECIMAL32_EconL 6 /* exp. continuation length */ - /* highest biased exponent (Elimit-1) */ + /* highest biased exponent (Elimit-1) */ #define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1) /* check enough digits, if pre-defined */ @@ -71,18 +71,18 @@ /* special values [top byte excluding sign bit; last two bits are */ /* don't-care for Infinity on input, last bit don't-care for NaN] */ #if !defined(DECIMAL_NaN) - #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ + #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ - #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ + #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ #endif /* ---------------------------------------------------------------- */ /* Routines */ /* ---------------------------------------------------------------- */ - #include "decimal32Symbols.h" +#include "decimal32Symbols.h" - /* String conversions */ + /* String conversions */ decimal32 * decimal32FromString(decimal32 *, const char *, decContext *); char * decimal32ToString(const decimal32 *, char *); char * decimal32ToEngString(const decimal32 *, char *); @@ -92,7 +92,7 @@ decContext *); decNumber * decimal32ToNumber(const decimal32 *, decNumber *); - /* Format-dependent utilities */ + /* Format-dependent utilities */ uint32_t decimal32IsCanonical(const decimal32 *); decimal32 * decimal32Canonical(decimal32 *, const decimal32 *); diff --git a/libdecnumber/dpd/decimal64.c b/libdecnumber/dpd/decimal64.c index 474eb7c..77684d8 100644 --- a/libdecnumber/dpd/decimal64.c +++ b/libdecnumber/dpd/decimal64.c @@ -29,7 +29,7 @@ 02110-1301, USA. */ /* ------------------------------------------------------------------ */ -/* Decimal 64-bit format module */ +/* Decimal 64-bit format module */ /* ------------------------------------------------------------------ */ /* This module comprises the routines for decimal64 format numbers. */ /* Conversions are supplied to and from decNumber and String. */ @@ -42,8 +42,8 @@ #include <string.h> /* [for memset/memcpy] */ #include <stdio.h> /* [for printf] */ -#include "dconfig.h" /* GCC definitions */ -#define DECNUMDIGITS 16 /* make decNumbers with space for 16 */ +#include "dconfig.h" /* GCC definitions */ +#define DECNUMDIGITS 16 /* make decNumbers with space for 16 */ #include "decNumber.h" /* base number library */ #include "decNumberLocal.h" /* decNumber local types, etc. */ #include "decimal64.h" /* our primary include */ @@ -75,9 +75,9 @@ extern void decNumberShow(const decNumber *); /* .. */ /* ------------------------------------------------------------------ */ /* decimal64FromNumber -- convert decNumber to decimal64 */ /* */ -/* ds is the target decimal64 */ +/* ds is the target decimal64 */ /* dn is the source number (assumed valid) */ -/* set is the context, used only for reporting errors */ +/* set is the context, used only for reporting errors */ /* */ /* The set argument is used only for status reporting and for the */ /* rounding mode (used if the coefficient is more than DECIMAL64_Pmax */ @@ -95,8 +95,8 @@ decimal64 * decimal64FromNumber(decimal64 *d64, const decNumber *dn, Int ae; /* adjusted exponent */ decNumber dw; /* work */ decContext dc; /* .. */ - uInt *pu; /* .. */ uInt comb, exp; /* .. */ + uInt uiwork; /* for macros */ uInt targar[2]={0, 0}; /* target 64-bit */ #define targhi targar[1] /* name the word with the sign */ #define targlo targar[0] /* and the other */ @@ -106,9 +106,9 @@ decimal64 * decimal64FromNumber(decimal64 *d64, const decNumber *dn, /* constraints. This could push the number to Infinity or zero, */ /* so this check and rounding must be done before generating the */ /* decimal64] */ - ae=dn->exponent+dn->digits-1; /* [0 if special] */ - if (dn->digits>DECIMAL64_Pmax /* too many digits */ - || ae>DECIMAL64_Emax /* likely overflow */ + ae=dn->exponent+dn->digits-1; /* [0 if special] */ + if (dn->digits>DECIMAL64_Pmax /* too many digits */ + || ae>DECIMAL64_Emax /* likely overflow */ || ae<DECIMAL64_Emin) { /* likely underflow */ decContextDefault(&dc, DEC_INIT_DECIMAL64); /* [no traps] */ dc.round=set->round; /* use supplied rounding */ @@ -122,7 +122,7 @@ decimal64 * decimal64FromNumber(decimal64 *d64, const decNumber *dn, if (dn->bits&DECSPECIAL) { /* a special value */ if (dn->bits&DECINF) targhi=DECIMAL_Inf<<24; else { /* sNaN or qNaN */ - if ((*dn->lsu!=0 || dn->digits>1) /* non-zero coefficient */ + if ((*dn->lsu!=0 || dn->digits>1) /* non-zero coefficient */ && (dn->digits<DECIMAL64_Pmax)) { /* coefficient fits */ decDigitsToDPD(dn, targar, 0); } @@ -148,7 +148,7 @@ decimal64 * decimal64FromNumber(decimal64 *d64, const decNumber *dn, comb=(exp>>5) & 0x18; /* msd=0, exp top 2 bits .. */ } else { /* non-zero finite number */ - uInt msd; /* work */ + uInt msd; /* work */ Int pad=0; /* coefficient pad digits */ /* the dn is known to fit, but it may need to be padded */ @@ -193,14 +193,15 @@ decimal64 * decimal64FromNumber(decimal64 *d64, const decNumber *dn, if (dn->bits&DECNEG) targhi|=0x80000000; /* add sign bit */ /* now write to storage; this is now always endian */ - pu=(uInt *)d64->bytes; /* overlay */ if (DECLITEND) { - pu[0]=targar[0]; /* directly store the low int */ - pu[1]=targar[1]; /* then the high int */ + /* lo int then hi */ + UBFROMUI(d64->bytes, targar[0]); + UBFROMUI(d64->bytes+4, targar[1]); } else { - pu[0]=targar[1]; /* directly store the high int */ - pu[1]=targar[0]; /* then the low int */ + /* hi int then lo */ + UBFROMUI(d64->bytes, targar[1]); + UBFROMUI(d64->bytes+4, targar[0]); } if (status!=0) decContextSetStatus(set, status); /* pass on status */ @@ -218,21 +219,20 @@ decNumber * decimal64ToNumber(const decimal64 *d64, decNumber *dn) { uInt msd; /* coefficient MSD */ uInt exp; /* exponent top two bits */ uInt comb; /* combination field */ - const uInt *pu; /* work */ - Int need; /* .. */ + Int need; /* work */ + uInt uiwork; /* for macros */ uInt sourar[2]; /* source 64-bit */ #define sourhi sourar[1] /* name the word with the sign */ #define sourlo sourar[0] /* and the lower word */ /* load source from storage; this is endian */ - pu=(const uInt *)d64->bytes; /* overlay */ if (DECLITEND) { - sourlo=pu[0]; /* directly load the low int */ - sourhi=pu[1]; /* then the high int */ + sourlo=UBTOUI(d64->bytes ); /* directly load the low int */ + sourhi=UBTOUI(d64->bytes+4); /* then the high int */ } else { - sourhi=pu[0]; /* directly load the high int */ - sourlo=pu[1]; /* then the low int */ + sourhi=UBTOUI(d64->bytes ); /* directly load the high int */ + sourlo=UBTOUI(d64->bytes+4); /* then the low int */ } comb=(sourhi>>26)&0x1f; /* combination field */ @@ -243,7 +243,7 @@ decNumber * decimal64ToNumber(const decimal64 *d64, decNumber *dn) { msd=COMBMSD[comb]; /* decode the combination field */ exp=COMBEXP[comb]; /* .. */ - if (exp==3) { /* is a special */ + if (exp==3) { /* is a special */ if (msd==0) { dn->bits|=DECINF; return dn; /* no coefficient needed */ @@ -281,11 +281,11 @@ decNumber * decimal64ToNumber(const decimal64 *d64, decNumber *dn) { /* ------------------------------------------------------------------ */ -/* to-scientific-string -- conversion to numeric string */ +/* to-scientific-string -- conversion to numeric string */ /* to-engineering-string -- conversion to numeric string */ /* */ /* decimal64ToString(d64, string); */ -/* decimal64ToEngString(d64, string); */ +/* decimal64ToEngString(d64, string); */ /* */ /* d64 is the decimal64 format number to convert */ /* string is the string where the result will be laid out */ @@ -295,7 +295,7 @@ decNumber * decimal64ToNumber(const decimal64 *d64, decNumber *dn) { /* No error is possible, and no status can be set. */ /* ------------------------------------------------------------------ */ char * decimal64ToEngString(const decimal64 *d64, char *string){ - decNumber dn; /* work */ + decNumber dn; /* work */ decimal64ToNumber(d64, &dn); decNumberToEngString(&dn, string); return string; @@ -305,27 +305,26 @@ char * decimal64ToString(const decimal64 *d64, char *string){ uInt msd; /* coefficient MSD */ Int exp; /* exponent top two bits or full */ uInt comb; /* combination field */ - char *cstart; /* coefficient start */ + char *cstart; /* coefficient start */ char *c; /* output pointer in string */ - const uInt *pu; /* work */ + const uByte *u; /* work */ char *s, *t; /* .. (source, target) */ Int dpd; /* .. */ Int pre, e; /* .. */ - const uByte *u; /* .. */ + uInt uiwork; /* for macros */ uInt sourar[2]; /* source 64-bit */ #define sourhi sourar[1] /* name the word with the sign */ #define sourlo sourar[0] /* and the lower word */ /* load source from storage; this is endian */ - pu=(const uInt *)d64->bytes; /* overlay */ if (DECLITEND) { - sourlo=pu[0]; /* directly load the low int */ - sourhi=pu[1]; /* then the high int */ + sourlo=UBTOUI(d64->bytes ); /* directly load the low int */ + sourhi=UBTOUI(d64->bytes+4); /* then the high int */ } else { - sourhi=pu[0]; /* directly load the high int */ - sourlo=pu[1]; /* then the low int */ + sourhi=UBTOUI(d64->bytes ); /* directly load the high int */ + sourlo=UBTOUI(d64->bytes+4); /* then the low int */ } c=string; /* where result will go */ @@ -337,7 +336,7 @@ char * decimal64ToString(const decimal64 *d64, char *string){ if (exp==3) { if (msd==0) { /* infinity */ - strcpy(c, "Inf"); + strcpy(c, "Inf"); strcpy(c+3, "inity"); return string; /* easy */ } @@ -362,7 +361,7 @@ char * decimal64ToString(const decimal64 *d64, char *string){ /* length. We use fixed-length memcpys because variable-length */ /* causes a subroutine call in GCC. (These are length 4 for speed */ /* and are safe because the array has an extra terminator byte.) */ - #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \ + #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \ if (c!=cstart) {memcpy(c, u+1, 4); c+=3;} \ else if (*u) {memcpy(c, u+4-*u, 4); c+=*u;} @@ -379,7 +378,7 @@ char * decimal64ToString(const decimal64 *d64, char *string){ if (c==cstart) *c++='0'; /* all zeros -- make 0 */ - if (exp==0) { /* integer or NaN case -- easy */ + if (exp==0) { /* integer or NaN case -- easy */ *c='\0'; /* terminate */ return string; } @@ -407,13 +406,13 @@ char * decimal64ToString(const decimal64 *d64, char *string){ /* finally add the E-part, if needed; it will never be 0, and has */ /* a maximum length of 3 digits */ if (e!=0) { - *c++='E'; /* starts with E */ - *c++='+'; /* assume positive */ + *c++='E'; /* starts with E */ + *c++='+'; /* assume positive */ if (e<0) { *(c-1)='-'; /* oops, need '-' */ e=-e; /* uInt, please */ } - u=&BIN2CHAR[e*4]; /* -> length byte */ + u=&BIN2CHAR[e*4]; /* -> length byte */ memcpy(c, u+4-*u, 4); /* copy fixed 4 characters [is safe] */ c+=*u; /* bump pointer appropriately */ } @@ -443,7 +442,7 @@ char * decimal64ToString(const decimal64 *d64, char *string){ /* the conversion */ /* *string is the character string which should contain a valid */ /* number (which may be a special value) */ -/* set is the context */ +/* set is the context */ /* */ /* The context is supplied to this routine is used for error handling */ /* (setting of status and traps) and for the rounding mode, only. */ @@ -452,7 +451,7 @@ char * decimal64ToString(const decimal64 *d64, char *string){ decimal64 * decimal64FromString(decimal64 *result, const char *string, decContext *set) { decContext dc; /* work */ - decNumber dn; /* .. */ + decNumber dn; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL64); /* no traps, please */ dc.round=set->round; /* use supplied rounding */ @@ -469,11 +468,11 @@ decimal64 * decimal64FromString(decimal64 *result, const char *string, /* ------------------------------------------------------------------ */ /* decimal64IsCanonical -- test whether encoding is canonical */ /* d64 is the source decimal64 */ -/* returns 1 if the encoding of d64 is canonical, 0 otherwise */ +/* returns 1 if the encoding of d64 is canonical, 0 otherwise */ /* No error is possible. */ /* ------------------------------------------------------------------ */ -uint32_t decimal64IsCanonical(const decimal64 *d64) { - decNumber dn; /* work */ +uInt decimal64IsCanonical(const decimal64 *d64) { + decNumber dn; /* work */ decimal64 canon; /* .. */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL64); @@ -490,7 +489,7 @@ uint32_t decimal64IsCanonical(const decimal64 *d64) { /* No error is possible. */ /* ------------------------------------------------------------------ */ decimal64 * decimal64Canonical(decimal64 *result, const decimal64 *d64) { - decNumber dn; /* work */ + decNumber dn; /* work */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL64); decimal64ToNumber(d64, &dn); @@ -520,8 +519,8 @@ decimal64 * decimal64Canonical(decimal64 *result, const decimal64 *d64) { /* This assumes range has been checked and exponent previously 0; */ /* type of exponent must be unsigned */ #define decimal64SetExpCon(d, e) { \ - (d)->bytes[0]|=(uint8_t)((e)>>6); \ - (d)->bytes[1]|=(uint8_t)(((e)&0x3F)<<2);} + (d)->bytes[0]|=(uByte)((e)>>6); \ + (d)->bytes[1]|=(uByte)(((e)&0x3F)<<2);} /* ------------------------------------------------------------------ */ /* decimal64Show -- display a decimal64 in hexadecimal [debug aid] */ @@ -591,12 +590,12 @@ const uInt COMBMSD[32]={0, 1, 2, 3, 4, 5, 6, 7, /* ------------------------------------------------------------------ */ /* decDigitsToDPD -- pack coefficient into DPD form */ /* */ -/* dn is the source number (assumed valid, max DECMAX754 digits) */ +/* dn is the source number (assumed valid, max DECMAX754 digits) */ /* targ is 1, 2, or 4-element uInt array, which the caller must */ -/* have cleared to zeros */ +/* have cleared to zeros */ /* shift is the number of 0 digits to add on the right (normally 0) */ /* */ -/* The coefficient must be known small enough to fit. The full */ +/* The coefficient must be known small enough to fit. The full */ /* coefficient is copied, including the leading 'odd' digit. This */ /* digit is retrieved and packed into the combination field by the */ /* caller. */ @@ -625,7 +624,7 @@ void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) { uInt dpd; /* densely packed decimal value */ uInt bin; /* binary value 0-999 */ uInt *uout=targ; /* -> current output uInt */ - uInt uoff=0; /* -> current output offset [from right] */ + uInt uoff=0; /* -> current output offset [from right] */ const Unit *inu=dn->lsu; /* -> current input unit */ Unit uar[DECMAXUNITS]; /* working copy of units, iff shifted */ #if DECDPUN!=3 /* not fast path */ @@ -636,7 +635,7 @@ void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) { /* shift the units array to the left by pad digits and copy */ /* [this code is a special case of decShiftToMost, which could */ /* be used instead if exposed and the array were copied first] */ - const Unit *source; /* .. */ + const Unit *source; /* .. */ Unit *target, *first; /* .. */ uInt next=0; /* work */ @@ -681,12 +680,12 @@ void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) { for(n=0; digits>0; n++) { /* each output bunch */ #if DECDPUN==3 /* fast path, 3-at-a-time */ - bin=*inu; /* 3 digits ready for convert */ + bin=*inu; /* 3 digits ready for convert */ digits-=3; /* [may go negative] */ inu++; /* may need another */ #else /* must collect digit-by-digit */ - Unit dig; /* current digit */ + Unit dig; /* current digit */ Int j; /* digit-in-declet count */ for (j=0; j<3; j++) { #if DECDPUN<=4 @@ -698,7 +697,7 @@ void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) { in=in/10; #endif if (j==0) bin=dig; - else if (j==1) bin+=X10(dig); + else if (j==1) bin+=X10(dig); else /* j==2 */ bin+=X100(dig); digits--; if (digits==0) break; /* [also protects *inu below] */ @@ -750,12 +749,12 @@ void decDigitsFromDPD(decNumber *dn, const uInt *sour, Int declets) { Int n; /* counter */ Unit *uout=dn->lsu; /* -> current output unit */ Unit *last=uout; /* will be unit containing msd */ - const uInt *uin=sour; /* -> current input uInt */ - uInt uoff=0; /* -> current input offset [from right] */ + const uInt *uin=sour; /* -> current input uInt */ + uInt uoff=0; /* -> current input offset [from right] */ #if DECDPUN!=3 uInt bcd; /* BCD result */ - uInt nibble; /* work */ + uInt nibble; /* work */ Unit out=0; /* accumulator */ Int cut=0; /* power of ten in current unit */ #endif @@ -772,7 +771,7 @@ void decDigitsFromDPD(decNumber *dn, const uInt *sour, Int declets) { uoff-=32; dpd|=*uin<<(10-uoff); /* get waiting bits */ } - dpd&=0x3ff; /* clear uninteresting bits */ + dpd&=0x3ff; /* clear uninteresting bits */ #if DECDPUN==3 if (dpd==0) *uout=0; @@ -822,9 +821,9 @@ void decDigitsFromDPD(decNumber *dn, const uInt *sour, Int declets) { cut++; if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;} } /* n */ - if (cut!=0) { /* some more left over */ + if (cut!=0) { /* some more left over */ *uout=out; /* write out final unit */ - if (out) last=uout; /* and note if non-zero */ + if (out) last=uout; /* and note if non-zero */ } #endif @@ -834,14 +833,14 @@ void decDigitsFromDPD(decNumber *dn, const uInt *sour, Int declets) { dn->digits=(last-dn->lsu)*DECDPUN+1; /* floor of digits, plus */ /* must be at least 1 digit */ #if DECDPUN>1 - if (*last<10) return; /* common odd digit or 0 */ - dn->digits++; /* must be 2 at least */ + if (*last<10) return; /* common odd digit or 0 */ + dn->digits++; /* must be 2 at least */ #if DECDPUN>2 if (*last<100) return; /* 10-99 */ - dn->digits++; /* must be 3 at least */ + dn->digits++; /* must be 3 at least */ #if DECDPUN>3 if (*last<1000) return; /* 100-999 */ - dn->digits++; /* must be 4 at least */ + dn->digits++; /* must be 4 at least */ #if DECDPUN>4 for (pow=&DECPOWERS[4]; *last>=*pow; pow++) dn->digits++; #endif diff --git a/libdecnumber/dpd/decimal64.h b/libdecnumber/dpd/decimal64.h index 549b626..95ae15f 100644 --- a/libdecnumber/dpd/decimal64.h +++ b/libdecnumber/dpd/decimal64.h @@ -35,7 +35,7 @@ #if !defined(DECIMAL64) #define DECIMAL64 #define DEC64NAME "decimal64" /* Short name */ - #define DEC64FULLNAME "Decimal 64-bit Number" /* Verbose name */ + #define DEC64FULLNAME "Decimal 64-bit Number" /* Verbose name */ #define DEC64AUTHOR "Mike Cowlishaw" /* Who to blame */ @@ -47,7 +47,7 @@ #define DECIMAL64_Bias 398 /* bias for the exponent */ #define DECIMAL64_String 24 /* maximum string length, +1 */ #define DECIMAL64_EconL 8 /* exp. continuation length */ - /* highest biased exponent (Elimit-1) */ + /* highest biased exponent (Elimit-1) */ #define DECIMAL64_Ehigh (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1) /* check enough digits, if pre-defined */ @@ -73,18 +73,18 @@ /* special values [top byte excluding sign bit; last two bits are */ /* don't-care for Infinity on input, last bit don't-care for NaN] */ #if !defined(DECIMAL_NaN) - #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ + #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ - #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ + #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ #endif /* ---------------------------------------------------------------- */ /* Routines */ /* ---------------------------------------------------------------- */ - #include "decimal64Symbols.h" +#include "decimal64Symbols.h" - /* String conversions */ + /* String conversions */ decimal64 * decimal64FromString(decimal64 *, const char *, decContext *); char * decimal64ToString(const decimal64 *, char *); char * decimal64ToEngString(const decimal64 *, char *); @@ -94,7 +94,7 @@ decContext *); decNumber * decimal64ToNumber(const decimal64 *, decNumber *); - /* Format-dependent utilities */ + /* Format-dependent utilities */ uint32_t decimal64IsCanonical(const decimal64 *); decimal64 * decimal64Canonical(decimal64 *, const decimal64 *); |