Lines Matching +full:4 +full:- +full:6

30 /* ------------------------------------------------------------------ */
32 /* ------------------------------------------------------------------ */
37 /* ------------------------------------------------------------------ */
48 /* Conditional code flag -- set this to match hardware platform */
49 /* 1=little-endian, 0=big-endian */
56 /* Conditional code flag -- set this to 1 for best performance */
59 /* Conditional check flags -- set these to 0 for best performance */
67 /* rounded up to a multiple of 4; must */
70 /* ---------------------------------------------------------------- */
71 /* Definitions for all modules (general-purpose) */
72 /* ---------------------------------------------------------------- */
74 /* Local names for common types -- for safety, decNumber modules do */
89 /* Development-use definitions */
99 extern const uByte DECSTICKYTAB[10]; /* re-round digits if sticky */
102 extern const uShort DPD2BIN[1024]; /* DPD -> 0-999 */
103 extern const uShort BIN2DPD[1000]; /* 0-999 -> DPD */
104 extern const uInt DPD2BINK[1024]; /* DPD -> 0-999000 */
105 extern const uInt DPD2BINM[1024]; /* DPD -> 0-999000000 */
106 extern const uByte DPD2BCD8[4096]; /* DPD -> ddd + len */
107 extern const uByte BIN2BCD8[4000]; /* 0-999 -> ddd + len */
108 extern const uShort BCD2DPD[2458]; /* 0-0x999 -> DPD (0x999=2457)*/
110 /* LONGMUL32HI -- set w=(u*v)>>32, where w, u, and v are uInts */
111 /* (that is, sets w to be the high-order word of the 64-bit result; */
112 /* the low-order word is simply u*v.) */
125 /* ROUNDUP -- round an integer up to a multiple of n */
126 #define ROUNDUP(i, n) ((((i)+(n)-1)/n)*n)
128 /* ROUNDDOWN -- round an integer down to a multiple of n */
130 #define ROUNDDOWN4(i) ((i)&~3) /* special for n=4 */
132 /* References to multi-byte sequences under different sizes */
139 /* X10 and X100 -- multiply integer i by 10 or 100 */
142 #define X100(i) (((i)<<2)+((i)<<5)+((i)<<6))
144 /* MAXI and MINI -- general max & min (not in ANSI) for integers */
154 /* ---------------------------------------------------------------- */
155 /* Definitions for arbitrary-precision modules (only valid after */
157 /* ---------------------------------------------------------------- */
162 #define DECNUMMINE -999999999 /* minimum adjusted exponent ditto */
173 /* Set DECDPUNMAX -- the maximum integer that fits in DECDPUN */
174 /* digits, and D2UTABLE -- the initializer for the D2U table */
177 #define D2UTABLE {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17, \
183 #define D2UTABLE {0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10, \
188 #define D2UTABLE {0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7, \
191 #elif DECDPUN==4
193 #define D2UTABLE {0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6, \
194 6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11, \
198 #define D2UTABLE {0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5, \
199 5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9, \
201 #elif DECDPUN==6
203 #define D2UTABLE {0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4, \
204 4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8, \
209 4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7, \
214 3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6, \
215 6,6,6,6,6,7}
219 3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5, \
220 5,5,6,6,6,6}
222 #error DECDPUN must be in the range 1-9
225 /* ----- Shared data (in decNumber.c) ----- */
230 /* ----- Macros ----- */
231 /* ISZERO -- return true if decNumber dn is a zero */
232 /* [performance-critical in some situations] */
235 /* D2U -- return the number of Units needed to hold d digits */
239 #elif DECDPUN==4
242 #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
244 /* SD2U -- static D2U macro (for compile-time calculation) */
245 #define SD2U(d) (((d)+DECDPUN-1)/DECDPUN)
247 /* MSUDIGITS -- returns digits in msu, from digits, calculated */
249 #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
251 /* D2N -- return the number of decNumber structs that would be */
257 ((((SD2U(d)-1)*sizeof(Unit))+sizeof(decNumber)*2-1)/sizeof(decNumber))
259 /* TODIGIT -- macro to remove the leading digit from the unsigned */
270 pow*=4; \
271 if ((u)>=pow) {(u)-=pow; *(c)+=8;} \
273 if ((u)>=pow) {(u)-=pow; *(c)+=4;} \
276 if ((u)>=pow) {(u)-=pow; *(c)+=2;} \
278 if ((u)>=pow) {(u)-=pow; *(c)+=1;} \
281 /* ---------------------------------------------------------------- */
282 /* Definitions for fixed-precision modules (only valid after */
284 /* ---------------------------------------------------------------- */
286 /* bcdnum -- a structure describing a format-independent finite */
289 uByte *msd; /* -> most significant digit */
290 uByte *lsd; /* -> least ditto */
300 #define NUMISSPECIAL(num) (EXPISSPECIAL((num)->exponent))
302 /* Refer to a 32-bit word or byte in a decFloat (df) by big-endian */
305 /* in the next-wider format (decFloatWider, or dfw) */
306 #define DECWORDS (DECBYTES/4)
307 #define DECWWORDS (DECWBYTES/4)
309 #define DFWORD(df, off) ((df)->words[DECWORDS-1-(off)])
310 #define DFBYTE(df, off) ((df)->bytes[DECBYTES-1-(off)])
311 #define DFWWORD(dfw, off) ((dfw)->words[DECWWORDS-1-(off)])
313 #define DFWORD(df, off) ((df)->words[off])
314 #define DFBYTE(df, off) ((df)->bytes[off])
315 #define DFWWORD(dfw, off) ((dfw)->words[off])
327 extern const uInt DECCOMBMSD[64]; /* Combination field -> MSD */
328 extern const uInt DECCOMBFROM[48]; /* exp+msd -> Combination */
335 /* Format-dependent macros and constants */
346 /* Format-dependent common tests: */
347 /* DFISZERO -- test for (any) zero */
348 /* DFISCCZERO -- test for coefficient continuation being zero */
349 /* DFISCC01 -- test for coefficient contains only 0s and 1s */
350 /* DFISINT -- test for finite and exponent q=0 */
351 /* DFISUINT01 -- test for sign=0, finite, exponent q=0, and */
354 /* In DFISZERO the first test checks the least-significant word */
355 /* (most likely to be non-zero); the penultimate tests MSD and */
406 /* [the top 2 bits will always be in the more-significant uInt] */
407 #define CANONDPDTWO(hi, lo, k) (((hi)&(0x300>>(32-(k))))==0 \
408 || ((hi)&(0x6e>>(32-(k))))!=(0x6e>>(32-(k))) \
411 /* Macro to test whether a full-length (length DECPMAX) BCD8 */
415 #define ISCOEFFZERO(u) (UINTAT((u)+DECPMAX-4)==0 \
416 && UINTAT((u)+DECPMAX-7)==0)
418 #define ISCOEFFZERO(u) (UINTAT((u)+DECPMAX-4)==0 \
419 && (UINTAT((u)+DECPMAX-8)+UINTAT((u)+DECPMAX-12) \
420 +UINTAT((u)+DECPMAX-16))==0)
422 #define ISCOEFFZERO(u) (UINTAT((u)+DECPMAX-4)==0 \
423 && (UINTAT((u)+DECPMAX-8) +UINTAT((u)+DECPMAX-12) \
424 +UINTAT((u)+DECPMAX-16)+UINTAT((u)+DECPMAX-20) \
425 +UINTAT((u)+DECPMAX-24)+UINTAT((u)+DECPMAX-28) \
426 +UINTAT((u)+DECPMAX-32)+USHORTAT((u)+DECPMAX-34))==0)
431 #define GETECON(df) ((Int)((DFWORD((df), 0)&0x03ffffff)>>(32-6-DECECONL)))
432 /* Ditto, from the next-wider format */
433 #define GETWECON(df) ((Int)((DFWWORD((df), 0)&0x03ffffff)>>(32-6-DECWECONL)))
437 #define GETEXPUN(df) ((Int)GETEXP(df)-DECBIAS)
441 /* Compile-time computes of the exponent continuation field masks */
443 #define ECONMASK ((0x03ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))
445 #define ECONNANMASK ((0x01ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))
450 /* In-line sequence to convert 10 bits at right end of uInt dpd */
456 UINTAT(u)=UINTAT(&DPD2BCD8[((dpd)&0x3ff)*4]);}
459 *(u)=DPD2BCD8[((dpd)&0x3ff)*4]; \
460 *(u+1)=DPD2BCD8[((dpd)&0x3ff)*4+1]; \
461 *(u+2)=DPD2BCD8[((dpd)&0x3ff)*4+2];}
464 /* to BCD8 using a table lookup (also used for variable-length */
465 /* decode). Each DPD decode is 3 bytes BCD8 plus a one-byte */
466 /* length which is not used, here). Fixed-length 4-byte moves */
474 /* GETWCOEFF extracts the coefficient of the next-wider format. */
475 /* The latter is a copy of the next-wider GETCOEFF using DFWWORD. */
482 dpd2bcd83(bcd+4, sourhi);}
488 dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30)); \
499 dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30)); \
509 dpd2bcd8(bcd+1, sourhi>>4); \
510 dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26)); \
512 dpd2bcd8(bcd+10, sourmh>>6); \
513 dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28)); \
528 dpd2bcd8(bcd+1, sourhi>>4); \
529 dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26)); \
531 dpd2bcd8(bcd+10, sourmh>>6); \
532 dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28)); \
544 /* a base-billion uInt array, with the least-significant */
545 /* 0-999999999 'digit' at offset 0. */
549 /* the usual DPD to binary, the other two pre-multiplied by 1000 */
586 (buf)[2]=DPD2BIN0[((sourmh<<4) | (sourml>>28))&0x3ff] \
587 +DPD2BINK[(sourmh>>6)&0x3ff] \
590 (buf)[3]=DPD2BIN0[((sourhi<<6) | (sourmh>>26))&0x3ff] \
591 +DPD2BINK[(sourhi>>4)&0x3ff] \
597 /* a base-thousand uInt array, with the least-significant 0-999 */
618 (buf)[4]=DPD2BIN[(sourhi>>8)&0x3ff]; \
630 (buf)[4]=DPD2BIN[(sourml>>8)&0x3ff]; \
633 (buf)[6]=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff]; \
634 (buf)[7]=DPD2BIN[(sourmh>>6)&0x3ff]; \
637 (buf)[9]=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff]; \
638 (buf)[10]=DPD2BIN[(sourhi>>4)&0x3ff]; \
659 /* [end of format-dependent macros and constants] */