intl/icu/source/i18n/decNumberLocal.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* ------------------------------------------------------------------ */
michael@0 2 /* decNumber package local type, tuning, and macro definitions */
michael@0 3 /* ------------------------------------------------------------------ */
michael@0 4 /* Copyright (c) IBM Corporation, 2000-2012. All rights reserved. */
michael@0 5 /* */
michael@0 6 /* This software is made available under the terms of the */
michael@0 7 /* ICU License -- ICU 1.8.1 and later. */
michael@0 8 /* */
michael@0 9 /* The description and User's Guide ("The decNumber C Library") for */
michael@0 10 /* this software is called decNumber.pdf. This document is */
michael@0 11 /* available, together with arithmetic and format specifications, */
michael@0 12 /* testcases, and Web links, on the General Decimal Arithmetic page. */
michael@0 13 /* */
michael@0 14 /* Please send comments, suggestions, and corrections to the author: */
michael@0 15 /* mfc@uk.ibm.com */
michael@0 16 /* Mike Cowlishaw, IBM Fellow */
michael@0 17 /* IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK */
michael@0 18 /* ------------------------------------------------------------------ */
michael@0 19 /* This header file is included by all modules in the decNumber */
michael@0 20 /* library, and contains local type definitions, tuning parameters, */
michael@0 21 /* etc. It should not need to be used by application programs. */
michael@0 22 /* decNumber.h or one of decDouble (etc.) must be included first. */
michael@0 23 /* ------------------------------------------------------------------ */
michael@0 24
michael@0 25 #if !defined(DECNUMBERLOC)
michael@0 26 #define DECNUMBERLOC
michael@0 27 #define DECVERSION "decNumber 3.61" /* Package Version [16 max.] */
michael@0 28 #define DECNLAUTHOR "Mike Cowlishaw" /* Who to blame */
michael@0 29
michael@0 30 #include <stdlib.h> /* for abs */
michael@0 31 #include <string.h> /* for memset, strcpy */
michael@0 32
michael@0 33 /* Conditional code flag -- set this to match hardware platform */
michael@0 34 #if !defined(DECLITEND)
michael@0 35 #define DECLITEND 1 /* 1=little-endian, 0=big-endian */
michael@0 36 #endif
michael@0 37
michael@0 38 /* Conditional code flag -- set this to 1 for best performance */
michael@0 39 #if !defined(DECUSE64)
michael@0 40 #define DECUSE64 1 /* 1=use int64s, 0=int32 & smaller only */
michael@0 41 #endif
michael@0 42
michael@0 43 /* Conditional check flags -- set these to 0 for best performance */
michael@0 44 #if !defined(DECCHECK)
michael@0 45 #define DECCHECK 0 /* 1 to enable robust checking */
michael@0 46 #endif
michael@0 47 #if !defined(DECALLOC)
michael@0 48 #define DECALLOC 0 /* 1 to enable memory accounting */
michael@0 49 #endif
michael@0 50 #if !defined(DECTRACE)
michael@0 51 #define DECTRACE 0 /* 1 to trace certain internals, etc. */
michael@0 52 #endif
michael@0 53
michael@0 54 /* Tuning parameter for decNumber (arbitrary precision) module */
michael@0 55 #if !defined(DECBUFFER)
michael@0 56 #define DECBUFFER 36 /* Size basis for local buffers. This */
michael@0 57 /* should be a common maximum precision */
michael@0 58 /* rounded up to a multiple of 4; must */
michael@0 59 /* be zero or positive. */
michael@0 60 #endif
michael@0 61
michael@0 62 /* ---------------------------------------------------------------- */
michael@0 63 /* Definitions for all modules (general-purpose) */
michael@0 64 /* ---------------------------------------------------------------- */
michael@0 65
michael@0 66 /* Local names for common types -- for safety, decNumber modules do */
michael@0 67 /* not use int or long directly. */
michael@0 68 #define Flag uint8_t
michael@0 69 #define Byte int8_t
michael@0 70 #define uByte uint8_t
michael@0 71 #define Short int16_t
michael@0 72 #define uShort uint16_t
michael@0 73 #define Int int32_t
michael@0 74 #define uInt uint32_t
michael@0 75 #define Unit decNumberUnit
michael@0 76 #if DECUSE64
michael@0 77 #define Long int64_t
michael@0 78 #define uLong uint64_t
michael@0 79 #endif
michael@0 80
michael@0 81 /* Development-use definitions */
michael@0 82 typedef long int LI; /* for printf arguments only */
michael@0 83 #define DECNOINT 0 /* 1 to check no internal use of 'int' */
michael@0 84 /* or stdint types */
michael@0 85 #if DECNOINT
michael@0 86 /* if these interfere with your C includes, do not set DECNOINT */
michael@0 87 #define int ? /* enable to ensure that plain C 'int' */
michael@0 88 #define long ?? /* .. or 'long' types are not used */
michael@0 89 #endif
michael@0 90
michael@0 91 /* LONGMUL32HI -- set w=(u*v)>>32, where w, u, and v are uInts */
michael@0 92 /* (that is, sets w to be the high-order word of the 64-bit result; */
michael@0 93 /* the low-order word is simply u*v.) */
michael@0 94 /* This version is derived from Knuth via Hacker's Delight; */
michael@0 95 /* it seems to optimize better than some others tried */
michael@0 96 #define LONGMUL32HI(w, u, v) { \
michael@0 97 uInt u0, u1, v0, v1, w0, w1, w2, t; \
michael@0 98 u0=u & 0xffff; u1=u>>16; \
michael@0 99 v0=v & 0xffff; v1=v>>16; \
michael@0 100 w0=u0*v0; \
michael@0 101 t=u1*v0 + (w0>>16); \
michael@0 102 w1=t & 0xffff; w2=t>>16; \
michael@0 103 w1=u0*v1 + w1; \
michael@0 104 (w)=u1*v1 + w2 + (w1>>16);}
michael@0 105
michael@0 106 /* ROUNDUP -- round an integer up to a multiple of n */
michael@0 107 #define ROUNDUP(i, n) ((((i)+(n)-1)/n)*n)
michael@0 108 #define ROUNDUP4(i) (((i)+3)&~3) /* special for n=4 */
michael@0 109
michael@0 110 /* ROUNDDOWN -- round an integer down to a multiple of n */
michael@0 111 #define ROUNDDOWN(i, n) (((i)/n)*n)
michael@0 112 #define ROUNDDOWN4(i) ((i)&~3) /* special for n=4 */
michael@0 113
michael@0 114 /* References to multi-byte sequences under different sizes; these */
michael@0 115 /* require locally declared variables, but do not violate strict */
michael@0 116 /* aliasing or alignment (as did the UINTAT simple cast to uInt). */
michael@0 117 /* Variables needed are uswork, uiwork, etc. [so do not use at same */
michael@0 118 /* level in an expression, e.g., UBTOUI(x)==UBTOUI(y) may fail]. */
michael@0 119
michael@0 120 /* Return a uInt, etc., from bytes starting at a char* or uByte* */
michael@0 121 #define UBTOUS(b) (memcpy((void *)&uswork, b, 2), uswork)
michael@0 122 #define UBTOUI(b) (memcpy((void *)&uiwork, b, 4), uiwork)
michael@0 123
michael@0 124 /* Store a uInt, etc., into bytes starting at a char* or uByte*. */
michael@0 125 /* Returns i, evaluated, for convenience; has to use uiwork because */
michael@0 126 /* i may be an expression. */
michael@0 127 #define UBFROMUS(b, i) (uswork=(i), memcpy(b, (void *)&uswork, 2), uswork)
michael@0 128 #define UBFROMUI(b, i) (uiwork=(i), memcpy(b, (void *)&uiwork, 4), uiwork)
michael@0 129
michael@0 130 /* X10 and X100 -- multiply integer i by 10 or 100 */
michael@0 131 /* [shifts are usually faster than multiply; could be conditional] */
michael@0 132 #define X10(i) (((i)<<1)+((i)<<3))
michael@0 133 #define X100(i) (((i)<<2)+((i)<<5)+((i)<<6))
michael@0 134
michael@0 135 /* MAXI and MINI -- general max & min (not in ANSI) for integers */
michael@0 136 #define MAXI(x,y) ((x)<(y)?(y):(x))
michael@0 137 #define MINI(x,y) ((x)>(y)?(y):(x))
michael@0 138
michael@0 139 /* Useful constants */
michael@0 140 #define BILLION 1000000000 /* 10**9 */
michael@0 141 /* CHARMASK: 0x30303030 for ASCII/UTF8; 0xF0F0F0F0 for EBCDIC */
michael@0 142 #define CHARMASK ((((((((uInt)'0')<<8)+'0')<<8)+'0')<<8)+'0')
michael@0 143
michael@0 144
michael@0 145 /* ---------------------------------------------------------------- */
michael@0 146 /* Definitions for arbitary-precision modules (only valid after */
michael@0 147 /* decNumber.h has been included) */
michael@0 148 /* ---------------------------------------------------------------- */
michael@0 149
michael@0 150 /* Limits and constants */
michael@0 151 #define DECNUMMAXP 999999999 /* maximum precision code can handle */
michael@0 152 #define DECNUMMAXE 999999999 /* maximum adjusted exponent ditto */
michael@0 153 #define DECNUMMINE -999999999 /* minimum adjusted exponent ditto */
michael@0 154 #if (DECNUMMAXP != DEC_MAX_DIGITS)
michael@0 155 #error Maximum digits mismatch
michael@0 156 #endif
michael@0 157 #if (DECNUMMAXE != DEC_MAX_EMAX)
michael@0 158 #error Maximum exponent mismatch
michael@0 159 #endif
michael@0 160 #if (DECNUMMINE != DEC_MIN_EMIN)
michael@0 161 #error Minimum exponent mismatch
michael@0 162 #endif
michael@0 163
michael@0 164 /* Set DECDPUNMAX -- the maximum integer that fits in DECDPUN */
michael@0 165 /* digits, and D2UTABLE -- the initializer for the D2U table */
michael@0 166 #if DECDPUN==1
michael@0 167 #define DECDPUNMAX 9
michael@0 168 #define D2UTABLE {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17, \
michael@0 169 18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, \
michael@0 170 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47, \
michael@0 171 48,49}
michael@0 172 #elif DECDPUN==2
michael@0 173 #define DECDPUNMAX 99
michael@0 174 #define D2UTABLE {0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10, \
michael@0 175 11,11,12,12,13,13,14,14,15,15,16,16,17,17,18, \
michael@0 176 18,19,19,20,20,21,21,22,22,23,23,24,24,25}
michael@0 177 #elif DECDPUN==3
michael@0 178 #define DECDPUNMAX 999
michael@0 179 #define D2UTABLE {0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7, \
michael@0 180 8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13, \
michael@0 181 13,14,14,14,15,15,15,16,16,16,17}
michael@0 182 #elif DECDPUN==4
michael@0 183 #define DECDPUNMAX 9999
michael@0 184 #define D2UTABLE {0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6, \
michael@0 185 6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11, \
michael@0 186 11,11,11,12,12,12,12,13}
michael@0 187 #elif DECDPUN==5
michael@0 188 #define DECDPUNMAX 99999
michael@0 189 #define D2UTABLE {0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5, \
michael@0 190 5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9, \
michael@0 191 9,9,10,10,10,10}
michael@0 192 #elif DECDPUN==6
michael@0 193 #define DECDPUNMAX 999999
michael@0 194 #define D2UTABLE {0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4, \
michael@0 195 4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8, \
michael@0 196 8,8,8,8,8,9}
michael@0 197 #elif DECDPUN==7
michael@0 198 #define DECDPUNMAX 9999999
michael@0 199 #define D2UTABLE {0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3, \
michael@0 200 4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7, \
michael@0 201 7,7,7,7,7,7}
michael@0 202 #elif DECDPUN==8
michael@0 203 #define DECDPUNMAX 99999999
michael@0 204 #define D2UTABLE {0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3, \
michael@0 205 3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6, \
michael@0 206 6,6,6,6,6,7}
michael@0 207 #elif DECDPUN==9
michael@0 208 #define DECDPUNMAX 999999999
michael@0 209 #define D2UTABLE {0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3, \
michael@0 210 3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5, \
michael@0 211 5,5,6,6,6,6}
michael@0 212 #elif defined(DECDPUN)
michael@0 213 #error DECDPUN must be in the range 1-9
michael@0 214 #endif
michael@0 215
michael@0 216 /* ----- Shared data (in decNumber.c) ----- */
michael@0 217 /* Public lookup table used by the D2U macro (see below) */
michael@0 218 #define DECMAXD2U 49
michael@0 219 /*extern const uByte d2utable[DECMAXD2U+1];*/
michael@0 220
michael@0 221 /* ----- Macros ----- */
michael@0 222 /* ISZERO -- return true if decNumber dn is a zero */
michael@0 223 /* [performance-critical in some situations] */
michael@0 224 #define ISZERO(dn) decNumberIsZero(dn) /* now just a local name */
michael@0 225
michael@0 226 /* D2U -- return the number of Units needed to hold d digits */
michael@0 227 /* (runtime version, with table lookaside for small d) */
michael@0 228 #if DECDPUN==8
michael@0 229 #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+7)>>3))
michael@0 230 #elif DECDPUN==4
michael@0 231 #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+3)>>2))
michael@0 232 #else
michael@0 233 #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
michael@0 234 #endif
michael@0 235 /* SD2U -- static D2U macro (for compile-time calculation) */
michael@0 236 #define SD2U(d) (((d)+DECDPUN-1)/DECDPUN)
michael@0 237
michael@0 238 /* MSUDIGITS -- returns digits in msu, from digits, calculated */
michael@0 239 /* using D2U */
michael@0 240 #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
michael@0 241
michael@0 242 /* D2N -- return the number of decNumber structs that would be */
michael@0 243 /* needed to contain that number of digits (and the initial */
michael@0 244 /* decNumber struct) safely. Note that one Unit is included in the */
michael@0 245 /* initial structure. Used for allocating space that is aligned on */
michael@0 246 /* a decNumber struct boundary. */
michael@0 247 #define D2N(d) \
michael@0 248 ((((SD2U(d)-1)*sizeof(Unit))+sizeof(decNumber)*2-1)/sizeof(decNumber))
michael@0 249
michael@0 250 /* TODIGIT -- macro to remove the leading digit from the unsigned */
michael@0 251 /* integer u at column cut (counting from the right, LSD=0) and */
michael@0 252 /* place it as an ASCII character into the character pointed to by */
michael@0 253 /* c. Note that cut must be <= 9, and the maximum value for u is */
michael@0 254 /* 2,000,000,000 (as is needed for negative exponents of */
michael@0 255 /* subnormals). The unsigned integer pow is used as a temporary */
michael@0 256 /* variable. */
michael@0 257 #define TODIGIT(u, cut, c, pow) { \
michael@0 258 *(c)='0'; \
michael@0 259 pow=DECPOWERS[cut]*2; \
michael@0 260 if ((u)>pow) { \
michael@0 261 pow*=4; \
michael@0 262 if ((u)>=pow) {(u)-=pow; *(c)+=8;} \
michael@0 263 pow/=2; \
michael@0 264 if ((u)>=pow) {(u)-=pow; *(c)+=4;} \
michael@0 265 pow/=2; \
michael@0 266 } \
michael@0 267 if ((u)>=pow) {(u)-=pow; *(c)+=2;} \
michael@0 268 pow/=2; \
michael@0 269 if ((u)>=pow) {(u)-=pow; *(c)+=1;} \
michael@0 270 }
michael@0 271
michael@0 272 /* ---------------------------------------------------------------- */
michael@0 273 /* Definitions for fixed-precision modules (only valid after */
michael@0 274 /* decSingle.h, decDouble.h, or decQuad.h has been included) */
michael@0 275 /* ---------------------------------------------------------------- */
michael@0 276
michael@0 277 /* bcdnum -- a structure describing a format-independent finite */
michael@0 278 /* number, whose coefficient is a string of bcd8 uBytes */
michael@0 279 typedef struct {
michael@0 280 uByte *msd; /* -> most significant digit */
michael@0 281 uByte *lsd; /* -> least ditto */
michael@0 282 uInt sign; /* 0=positive, DECFLOAT_Sign=negative */
michael@0 283 Int exponent; /* Unadjusted signed exponent (q), or */
michael@0 284 /* DECFLOAT_NaN etc. for a special */
michael@0 285 } bcdnum;
michael@0 286
michael@0 287 /* Test if exponent or bcdnum exponent must be a special, etc. */
michael@0 288 #define EXPISSPECIAL(exp) ((exp)>=DECFLOAT_MinSp)
michael@0 289 #define EXPISINF(exp) (exp==DECFLOAT_Inf)
michael@0 290 #define EXPISNAN(exp) (exp==DECFLOAT_qNaN || exp==DECFLOAT_sNaN)
michael@0 291 #define NUMISSPECIAL(num) (EXPISSPECIAL((num)->exponent))
michael@0 292
michael@0 293 /* Refer to a 32-bit word or byte in a decFloat (df) by big-endian */
michael@0 294 /* (array) notation (the 0 word or byte contains the sign bit), */
michael@0 295 /* automatically adjusting for endianness; similarly address a word */
michael@0 296 /* in the next-wider format (decFloatWider, or dfw) */
michael@0 297 #define DECWORDS (DECBYTES/4)
michael@0 298 #define DECWWORDS (DECWBYTES/4)
michael@0 299 #if DECLITEND
michael@0 300 #define DFBYTE(df, off) ((df)->bytes[DECBYTES-1-(off)])
michael@0 301 #define DFWORD(df, off) ((df)->words[DECWORDS-1-(off)])
michael@0 302 #define DFWWORD(dfw, off) ((dfw)->words[DECWWORDS-1-(off)])
michael@0 303 #else
michael@0 304 #define DFBYTE(df, off) ((df)->bytes[off])
michael@0 305 #define DFWORD(df, off) ((df)->words[off])
michael@0 306 #define DFWWORD(dfw, off) ((dfw)->words[off])
michael@0 307 #endif
michael@0 308
michael@0 309 /* Tests for sign or specials, directly on DECFLOATs */
michael@0 310 #define DFISSIGNED(df) (DFWORD(df, 0)&0x80000000)
michael@0 311 #define DFISSPECIAL(df) ((DFWORD(df, 0)&0x78000000)==0x78000000)
michael@0 312 #define DFISINF(df) ((DFWORD(df, 0)&0x7c000000)==0x78000000)
michael@0 313 #define DFISNAN(df) ((DFWORD(df, 0)&0x7c000000)==0x7c000000)
michael@0 314 #define DFISQNAN(df) ((DFWORD(df, 0)&0x7e000000)==0x7c000000)
michael@0 315 #define DFISSNAN(df) ((DFWORD(df, 0)&0x7e000000)==0x7e000000)
michael@0 316
michael@0 317 /* Shared lookup tables */
michael@0 318 extern const uInt DECCOMBMSD[64]; /* Combination field -> MSD */
michael@0 319 extern const uInt DECCOMBFROM[48]; /* exp+msd -> Combination */
michael@0 320
michael@0 321 /* Private generic (utility) routine */
michael@0 322 #if DECCHECK || DECTRACE
michael@0 323 extern void decShowNum(const bcdnum *, const char *);
michael@0 324 #endif
michael@0 325
michael@0 326 /* Format-dependent macros and constants */
michael@0 327 #if defined(DECPMAX)
michael@0 328
michael@0 329 /* Useful constants */
michael@0 330 #define DECPMAX9 (ROUNDUP(DECPMAX, 9)/9) /* 'Pmax' in 10**9s */
michael@0 331 /* Top words for a zero */
michael@0 332 #define SINGLEZERO 0x22500000
michael@0 333 #define DOUBLEZERO 0x22380000
michael@0 334 #define QUADZERO 0x22080000
michael@0 335 /* [ZEROWORD is defined to be one of these in the DFISZERO macro] */
michael@0 336
michael@0 337 /* Format-dependent common tests: */
michael@0 338 /* DFISZERO -- test for (any) zero */
michael@0 339 /* DFISCCZERO -- test for coefficient continuation being zero */
michael@0 340 /* DFISCC01 -- test for coefficient contains only 0s and 1s */
michael@0 341 /* DFISINT -- test for finite and exponent q=0 */
michael@0 342 /* DFISUINT01 -- test for sign=0, finite, exponent q=0, and */
michael@0 343 /* MSD=0 or 1 */
michael@0 344 /* ZEROWORD is also defined here. */
michael@0 345 /* In DFISZERO the first test checks the least-significant word */
michael@0 346 /* (most likely to be non-zero); the penultimate tests MSD and */
michael@0 347 /* DPDs in the signword, and the final test excludes specials and */
michael@0 348 /* MSD>7. DFISINT similarly has to allow for the two forms of */
michael@0 349 /* MSD codes. DFISUINT01 only has to allow for one form of MSD */
michael@0 350 /* code. */
michael@0 351 #if DECPMAX==7
michael@0 352 #define ZEROWORD SINGLEZERO
michael@0 353 /* [test macros not needed except for Zero] */
michael@0 354 #define DFISZERO(df) ((DFWORD(df, 0)&0x1c0fffff)==0 \
michael@0 355 && (DFWORD(df, 0)&0x60000000)!=0x60000000)
michael@0 356 #elif DECPMAX==16
michael@0 357 #define ZEROWORD DOUBLEZERO
michael@0 358 #define DFISZERO(df) ((DFWORD(df, 1)==0 \
michael@0 359 && (DFWORD(df, 0)&0x1c03ffff)==0 \
michael@0 360 && (DFWORD(df, 0)&0x60000000)!=0x60000000))
michael@0 361 #define DFISINT(df) ((DFWORD(df, 0)&0x63fc0000)==0x22380000 \
michael@0 362 ||(DFWORD(df, 0)&0x7bfc0000)==0x6a380000)
michael@0 363 #define DFISUINT01(df) ((DFWORD(df, 0)&0xfbfc0000)==0x22380000)
michael@0 364 #define DFISCCZERO(df) (DFWORD(df, 1)==0 \
michael@0 365 && (DFWORD(df, 0)&0x0003ffff)==0)
michael@0 366 #define DFISCC01(df) ((DFWORD(df, 0)&~0xfffc9124)==0 \
michael@0 367 && (DFWORD(df, 1)&~0x49124491)==0)
michael@0 368 #elif DECPMAX==34
michael@0 369 #define ZEROWORD QUADZERO
michael@0 370 #define DFISZERO(df) ((DFWORD(df, 3)==0 \
michael@0 371 && DFWORD(df, 2)==0 \
michael@0 372 && DFWORD(df, 1)==0 \
michael@0 373 && (DFWORD(df, 0)&0x1c003fff)==0 \
michael@0 374 && (DFWORD(df, 0)&0x60000000)!=0x60000000))
michael@0 375 #define DFISINT(df) ((DFWORD(df, 0)&0x63ffc000)==0x22080000 \
michael@0 376 ||(DFWORD(df, 0)&0x7bffc000)==0x6a080000)
michael@0 377 #define DFISUINT01(df) ((DFWORD(df, 0)&0xfbffc000)==0x22080000)
michael@0 378 #define DFISCCZERO(df) (DFWORD(df, 3)==0 \
michael@0 379 && DFWORD(df, 2)==0 \
michael@0 380 && DFWORD(df, 1)==0 \
michael@0 381 && (DFWORD(df, 0)&0x00003fff)==0)
michael@0 382
michael@0 383 #define DFISCC01(df) ((DFWORD(df, 0)&~0xffffc912)==0 \
michael@0 384 && (DFWORD(df, 1)&~0x44912449)==0 \
michael@0 385 && (DFWORD(df, 2)&~0x12449124)==0 \
michael@0 386 && (DFWORD(df, 3)&~0x49124491)==0)
michael@0 387 #endif
michael@0 388
michael@0 389 /* Macros to test if a certain 10 bits of a uInt or pair of uInts */
michael@0 390 /* are a canonical declet [higher or lower bits are ignored]. */
michael@0 391 /* declet is at offset 0 (from the right) in a uInt: */
michael@0 392 #define CANONDPD(dpd) (((dpd)&0x300)==0 || ((dpd)&0x6e)!=0x6e)
michael@0 393 /* declet is at offset k (a multiple of 2) in a uInt: */
michael@0 394 #define CANONDPDOFF(dpd, k) (((dpd)&(0x300<<(k)))==0 \
michael@0 395 || ((dpd)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k)))
michael@0 396 /* declet is at offset k (a multiple of 2) in a pair of uInts: */
michael@0 397 /* [the top 2 bits will always be in the more-significant uInt] */
michael@0 398 #define CANONDPDTWO(hi, lo, k) (((hi)&(0x300>>(32-(k))))==0 \
michael@0 399 || ((hi)&(0x6e>>(32-(k))))!=(0x6e>>(32-(k))) \
michael@0 400 || ((lo)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k)))
michael@0 401
michael@0 402 /* Macro to test whether a full-length (length DECPMAX) BCD8 */
michael@0 403 /* coefficient, starting at uByte u, is all zeros */
michael@0 404 /* Test just the LSWord first, then the remainder as a sequence */
michael@0 405 /* of tests in order to avoid same-level use of UBTOUI */
michael@0 406 #if DECPMAX==7
michael@0 407 #define ISCOEFFZERO(u) ( \
michael@0 408 UBTOUI((u)+DECPMAX-4)==0 \
michael@0 409 && UBTOUS((u)+DECPMAX-6)==0 \
michael@0 410 && *(u)==0)
michael@0 411 #elif DECPMAX==16
michael@0 412 #define ISCOEFFZERO(u) ( \
michael@0 413 UBTOUI((u)+DECPMAX-4)==0 \
michael@0 414 && UBTOUI((u)+DECPMAX-8)==0 \
michael@0 415 && UBTOUI((u)+DECPMAX-12)==0 \
michael@0 416 && UBTOUI(u)==0)
michael@0 417 #elif DECPMAX==34
michael@0 418 #define ISCOEFFZERO(u) ( \
michael@0 419 UBTOUI((u)+DECPMAX-4)==0 \
michael@0 420 && UBTOUI((u)+DECPMAX-8)==0 \
michael@0 421 && UBTOUI((u)+DECPMAX-12)==0 \
michael@0 422 && UBTOUI((u)+DECPMAX-16)==0 \
michael@0 423 && UBTOUI((u)+DECPMAX-20)==0 \
michael@0 424 && UBTOUI((u)+DECPMAX-24)==0 \
michael@0 425 && UBTOUI((u)+DECPMAX-28)==0 \
michael@0 426 && UBTOUI((u)+DECPMAX-32)==0 \
michael@0 427 && UBTOUS(u)==0)
michael@0 428 #endif
michael@0 429
michael@0 430 /* Macros and masks for the exponent continuation field and MSD */
michael@0 431 /* Get the exponent continuation from a decFloat *df as an Int */
michael@0 432 #define GETECON(df) ((Int)((DFWORD((df), 0)&0x03ffffff)>>(32-6-DECECONL)))
michael@0 433 /* Ditto, from the next-wider format */
michael@0 434 #define GETWECON(df) ((Int)((DFWWORD((df), 0)&0x03ffffff)>>(32-6-DECWECONL)))
michael@0 435 /* Get the biased exponent similarly */
michael@0 436 #define GETEXP(df) ((Int)(DECCOMBEXP[DFWORD((df), 0)>>26]+GETECON(df)))
michael@0 437 /* Get the unbiased exponent similarly */
michael@0 438 #define GETEXPUN(df) ((Int)GETEXP(df)-DECBIAS)
michael@0 439 /* Get the MSD similarly (as uInt) */
michael@0 440 #define GETMSD(df) (DECCOMBMSD[DFWORD((df), 0)>>26])
michael@0 441
michael@0 442 /* Compile-time computes of the exponent continuation field masks */
michael@0 443 /* full exponent continuation field: */
michael@0 444 #define ECONMASK ((0x03ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))
michael@0 445 /* same, not including its first digit (the qNaN/sNaN selector): */
michael@0 446 #define ECONNANMASK ((0x01ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))
michael@0 447
michael@0 448 /* Macros to decode the coefficient in a finite decFloat *df into */
michael@0 449 /* a BCD string (uByte *bcdin) of length DECPMAX uBytes. */
michael@0 450
michael@0 451 /* In-line sequence to convert least significant 10 bits of uInt */
michael@0 452 /* dpd to three BCD8 digits starting at uByte u. Note that an */
michael@0 453 /* extra byte is written to the right of the three digits because */
michael@0 454 /* four bytes are moved at a time for speed; the alternative */
michael@0 455 /* macro moves exactly three bytes (usually slower). */
michael@0 456 #define dpd2bcd8(u, dpd) memcpy(u, &DPD2BCD8[((dpd)&0x3ff)*4], 4)
michael@0 457 #define dpd2bcd83(u, dpd) memcpy(u, &DPD2BCD8[((dpd)&0x3ff)*4], 3)
michael@0 458
michael@0 459 /* Decode the declets. After extracting each one, it is decoded */
michael@0 460 /* to BCD8 using a table lookup (also used for variable-length */
michael@0 461 /* decode). Each DPD decode is 3 bytes BCD8 plus a one-byte */
michael@0 462 /* length which is not used, here). Fixed-length 4-byte moves */
michael@0 463 /* are fast, however, almost everywhere, and so are used except */
michael@0 464 /* for the final three bytes (to avoid overrun). The code below */
michael@0 465 /* is 36 instructions for Doubles and about 70 for Quads, even */
michael@0 466 /* on IA32. */
michael@0 467
michael@0 468 /* Two macros are defined for each format: */
michael@0 469 /* GETCOEFF extracts the coefficient of the current format */
michael@0 470 /* GETWCOEFF extracts the coefficient of the next-wider format. */
michael@0 471 /* The latter is a copy of the next-wider GETCOEFF using DFWWORD. */
michael@0 472
michael@0 473 #if DECPMAX==7
michael@0 474 #define GETCOEFF(df, bcd) { \
michael@0 475 uInt sourhi=DFWORD(df, 0); \
michael@0 476 *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
michael@0 477 dpd2bcd8(bcd+1, sourhi>>10); \
michael@0 478 dpd2bcd83(bcd+4, sourhi);}
michael@0 479 #define GETWCOEFF(df, bcd) { \
michael@0 480 uInt sourhi=DFWWORD(df, 0); \
michael@0 481 uInt sourlo=DFWWORD(df, 1); \
michael@0 482 *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
michael@0 483 dpd2bcd8(bcd+1, sourhi>>8); \
michael@0 484 dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30)); \
michael@0 485 dpd2bcd8(bcd+7, sourlo>>20); \
michael@0 486 dpd2bcd8(bcd+10, sourlo>>10); \
michael@0 487 dpd2bcd83(bcd+13, sourlo);}
michael@0 488
michael@0 489 #elif DECPMAX==16
michael@0 490 #define GETCOEFF(df, bcd) { \
michael@0 491 uInt sourhi=DFWORD(df, 0); \
michael@0 492 uInt sourlo=DFWORD(df, 1); \
michael@0 493 *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
michael@0 494 dpd2bcd8(bcd+1, sourhi>>8); \
michael@0 495 dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30)); \
michael@0 496 dpd2bcd8(bcd+7, sourlo>>20); \
michael@0 497 dpd2bcd8(bcd+10, sourlo>>10); \
michael@0 498 dpd2bcd83(bcd+13, sourlo);}
michael@0 499 #define GETWCOEFF(df, bcd) { \
michael@0 500 uInt sourhi=DFWWORD(df, 0); \
michael@0 501 uInt sourmh=DFWWORD(df, 1); \
michael@0 502 uInt sourml=DFWWORD(df, 2); \
michael@0 503 uInt sourlo=DFWWORD(df, 3); \
michael@0 504 *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
michael@0 505 dpd2bcd8(bcd+1, sourhi>>4); \
michael@0 506 dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26)); \
michael@0 507 dpd2bcd8(bcd+7, sourmh>>16); \
michael@0 508 dpd2bcd8(bcd+10, sourmh>>6); \
michael@0 509 dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28)); \
michael@0 510 dpd2bcd8(bcd+16, sourml>>18); \
michael@0 511 dpd2bcd8(bcd+19, sourml>>8); \
michael@0 512 dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30)); \
michael@0 513 dpd2bcd8(bcd+25, sourlo>>20); \
michael@0 514 dpd2bcd8(bcd+28, sourlo>>10); \
michael@0 515 dpd2bcd83(bcd+31, sourlo);}
michael@0 516
michael@0 517 #elif DECPMAX==34
michael@0 518 #define GETCOEFF(df, bcd) { \
michael@0 519 uInt sourhi=DFWORD(df, 0); \
michael@0 520 uInt sourmh=DFWORD(df, 1); \
michael@0 521 uInt sourml=DFWORD(df, 2); \
michael@0 522 uInt sourlo=DFWORD(df, 3); \
michael@0 523 *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
michael@0 524 dpd2bcd8(bcd+1, sourhi>>4); \
michael@0 525 dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26)); \
michael@0 526 dpd2bcd8(bcd+7, sourmh>>16); \
michael@0 527 dpd2bcd8(bcd+10, sourmh>>6); \
michael@0 528 dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28)); \
michael@0 529 dpd2bcd8(bcd+16, sourml>>18); \
michael@0 530 dpd2bcd8(bcd+19, sourml>>8); \
michael@0 531 dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30)); \
michael@0 532 dpd2bcd8(bcd+25, sourlo>>20); \
michael@0 533 dpd2bcd8(bcd+28, sourlo>>10); \
michael@0 534 dpd2bcd83(bcd+31, sourlo);}
michael@0 535
michael@0 536 #define GETWCOEFF(df, bcd) {??} /* [should never be used] */
michael@0 537 #endif
michael@0 538
michael@0 539 /* Macros to decode the coefficient in a finite decFloat *df into */
michael@0 540 /* a base-billion uInt array, with the least-significant */
michael@0 541 /* 0-999999999 'digit' at offset 0. */
michael@0 542
michael@0 543 /* Decode the declets. After extracting each one, it is decoded */
michael@0 544 /* to binary using a table lookup. Three tables are used; one */
michael@0 545 /* the usual DPD to binary, the other two pre-multiplied by 1000 */
michael@0 546 /* and 1000000 to avoid multiplication during decode. These */
michael@0 547 /* tables can also be used for multiplying up the MSD as the DPD */
michael@0 548 /* code for 0 through 9 is the identity. */
michael@0 549 #define DPD2BIN0 DPD2BIN /* for prettier code */
michael@0 550
michael@0 551 #if DECPMAX==7
michael@0 552 #define GETCOEFFBILL(df, buf) { \
michael@0 553 uInt sourhi=DFWORD(df, 0); \
michael@0 554 (buf)[0]=DPD2BIN0[sourhi&0x3ff] \
michael@0 555 +DPD2BINK[(sourhi>>10)&0x3ff] \
michael@0 556 +DPD2BINM[DECCOMBMSD[sourhi>>26]];}
michael@0 557
michael@0 558 #elif DECPMAX==16
michael@0 559 #define GETCOEFFBILL(df, buf) { \
michael@0 560 uInt sourhi, sourlo; \
michael@0 561 sourlo=DFWORD(df, 1); \
michael@0 562 (buf)[0]=DPD2BIN0[sourlo&0x3ff] \
michael@0 563 +DPD2BINK[(sourlo>>10)&0x3ff] \
michael@0 564 +DPD2BINM[(sourlo>>20)&0x3ff]; \
michael@0 565 sourhi=DFWORD(df, 0); \
michael@0 566 (buf)[1]=DPD2BIN0[((sourhi<<2) | (sourlo>>30))&0x3ff] \
michael@0 567 +DPD2BINK[(sourhi>>8)&0x3ff] \
michael@0 568 +DPD2BINM[DECCOMBMSD[sourhi>>26]];}
michael@0 569
michael@0 570 #elif DECPMAX==34
michael@0 571 #define GETCOEFFBILL(df, buf) { \
michael@0 572 uInt sourhi, sourmh, sourml, sourlo; \
michael@0 573 sourlo=DFWORD(df, 3); \
michael@0 574 (buf)[0]=DPD2BIN0[sourlo&0x3ff] \
michael@0 575 +DPD2BINK[(sourlo>>10)&0x3ff] \
michael@0 576 +DPD2BINM[(sourlo>>20)&0x3ff]; \
michael@0 577 sourml=DFWORD(df, 2); \
michael@0 578 (buf)[1]=DPD2BIN0[((sourml<<2) | (sourlo>>30))&0x3ff] \
michael@0 579 +DPD2BINK[(sourml>>8)&0x3ff] \
michael@0 580 +DPD2BINM[(sourml>>18)&0x3ff]; \
michael@0 581 sourmh=DFWORD(df, 1); \
michael@0 582 (buf)[2]=DPD2BIN0[((sourmh<<4) | (sourml>>28))&0x3ff] \
michael@0 583 +DPD2BINK[(sourmh>>6)&0x3ff] \
michael@0 584 +DPD2BINM[(sourmh>>16)&0x3ff]; \
michael@0 585 sourhi=DFWORD(df, 0); \
michael@0 586 (buf)[3]=DPD2BIN0[((sourhi<<6) | (sourmh>>26))&0x3ff] \
michael@0 587 +DPD2BINK[(sourhi>>4)&0x3ff] \
michael@0 588 +DPD2BINM[DECCOMBMSD[sourhi>>26]];}
michael@0 589
michael@0 590 #endif
michael@0 591
michael@0 592 /* Macros to decode the coefficient in a finite decFloat *df into */
michael@0 593 /* a base-thousand uInt array (of size DECLETS+1, to allow for */
michael@0 594 /* the MSD), with the least-significant 0-999 'digit' at offset 0.*/
michael@0 595
michael@0 596 /* Decode the declets. After extracting each one, it is decoded */
michael@0 597 /* to binary using a table lookup. */
michael@0 598 #if DECPMAX==7
michael@0 599 #define GETCOEFFTHOU(df, buf) { \
michael@0 600 uInt sourhi=DFWORD(df, 0); \
michael@0 601 (buf)[0]=DPD2BIN[sourhi&0x3ff]; \
michael@0 602 (buf)[1]=DPD2BIN[(sourhi>>10)&0x3ff]; \
michael@0 603 (buf)[2]=DECCOMBMSD[sourhi>>26];}
michael@0 604
michael@0 605 #elif DECPMAX==16
michael@0 606 #define GETCOEFFTHOU(df, buf) { \
michael@0 607 uInt sourhi, sourlo; \
michael@0 608 sourlo=DFWORD(df, 1); \
michael@0 609 (buf)[0]=DPD2BIN[sourlo&0x3ff]; \
michael@0 610 (buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff]; \
michael@0 611 (buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff]; \
michael@0 612 sourhi=DFWORD(df, 0); \
michael@0 613 (buf)[3]=DPD2BIN[((sourhi<<2) | (sourlo>>30))&0x3ff]; \
michael@0 614 (buf)[4]=DPD2BIN[(sourhi>>8)&0x3ff]; \
michael@0 615 (buf)[5]=DECCOMBMSD[sourhi>>26];}
michael@0 616
michael@0 617 #elif DECPMAX==34
michael@0 618 #define GETCOEFFTHOU(df, buf) { \
michael@0 619 uInt sourhi, sourmh, sourml, sourlo; \
michael@0 620 sourlo=DFWORD(df, 3); \
michael@0 621 (buf)[0]=DPD2BIN[sourlo&0x3ff]; \
michael@0 622 (buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff]; \
michael@0 623 (buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff]; \
michael@0 624 sourml=DFWORD(df, 2); \
michael@0 625 (buf)[3]=DPD2BIN[((sourml<<2) | (sourlo>>30))&0x3ff]; \
michael@0 626 (buf)[4]=DPD2BIN[(sourml>>8)&0x3ff]; \
michael@0 627 (buf)[5]=DPD2BIN[(sourml>>18)&0x3ff]; \
michael@0 628 sourmh=DFWORD(df, 1); \
michael@0 629 (buf)[6]=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff]; \
michael@0 630 (buf)[7]=DPD2BIN[(sourmh>>6)&0x3ff]; \
michael@0 631 (buf)[8]=DPD2BIN[(sourmh>>16)&0x3ff]; \
michael@0 632 sourhi=DFWORD(df, 0); \
michael@0 633 (buf)[9]=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff]; \
michael@0 634 (buf)[10]=DPD2BIN[(sourhi>>4)&0x3ff]; \
michael@0 635 (buf)[11]=DECCOMBMSD[sourhi>>26];}
michael@0 636 #endif
michael@0 637
michael@0 638
michael@0 639 /* Macros to decode the coefficient in a finite decFloat *df and */
michael@0 640 /* add to a base-thousand uInt array (as for GETCOEFFTHOU). */
michael@0 641 /* After the addition then most significant 'digit' in the array */
michael@0 642 /* might have a value larger then 10 (with a maximum of 19). */
michael@0 643 #if DECPMAX==7
michael@0 644 #define ADDCOEFFTHOU(df, buf) { \
michael@0 645 uInt sourhi=DFWORD(df, 0); \
michael@0 646 (buf)[0]+=DPD2BIN[sourhi&0x3ff]; \
michael@0 647 if (buf[0]>999) {buf[0]-=1000; buf[1]++;} \
michael@0 648 (buf)[1]+=DPD2BIN[(sourhi>>10)&0x3ff]; \
michael@0 649 if (buf[1]>999) {buf[1]-=1000; buf[2]++;} \
michael@0 650 (buf)[2]+=DECCOMBMSD[sourhi>>26];}
michael@0 651
michael@0 652 #elif DECPMAX==16
michael@0 653 #define ADDCOEFFTHOU(df, buf) { \
michael@0 654 uInt sourhi, sourlo; \
michael@0 655 sourlo=DFWORD(df, 1); \
michael@0 656 (buf)[0]+=DPD2BIN[sourlo&0x3ff]; \
michael@0 657 if (buf[0]>999) {buf[0]-=1000; buf[1]++;} \
michael@0 658 (buf)[1]+=DPD2BIN[(sourlo>>10)&0x3ff]; \
michael@0 659 if (buf[1]>999) {buf[1]-=1000; buf[2]++;} \
michael@0 660 (buf)[2]+=DPD2BIN[(sourlo>>20)&0x3ff]; \
michael@0 661 if (buf[2]>999) {buf[2]-=1000; buf[3]++;} \
michael@0 662 sourhi=DFWORD(df, 0); \
michael@0 663 (buf)[3]+=DPD2BIN[((sourhi<<2) | (sourlo>>30))&0x3ff]; \
michael@0 664 if (buf[3]>999) {buf[3]-=1000; buf[4]++;} \
michael@0 665 (buf)[4]+=DPD2BIN[(sourhi>>8)&0x3ff]; \
michael@0 666 if (buf[4]>999) {buf[4]-=1000; buf[5]++;} \
michael@0 667 (buf)[5]+=DECCOMBMSD[sourhi>>26];}
michael@0 668
michael@0 669 #elif DECPMAX==34
michael@0 670 #define ADDCOEFFTHOU(df, buf) { \
michael@0 671 uInt sourhi, sourmh, sourml, sourlo; \
michael@0 672 sourlo=DFWORD(df, 3); \
michael@0 673 (buf)[0]+=DPD2BIN[sourlo&0x3ff]; \
michael@0 674 if (buf[0]>999) {buf[0]-=1000; buf[1]++;} \
michael@0 675 (buf)[1]+=DPD2BIN[(sourlo>>10)&0x3ff]; \
michael@0 676 if (buf[1]>999) {buf[1]-=1000; buf[2]++;} \
michael@0 677 (buf)[2]+=DPD2BIN[(sourlo>>20)&0x3ff]; \
michael@0 678 if (buf[2]>999) {buf[2]-=1000; buf[3]++;} \
michael@0 679 sourml=DFWORD(df, 2); \
michael@0 680 (buf)[3]+=DPD2BIN[((sourml<<2) | (sourlo>>30))&0x3ff]; \
michael@0 681 if (buf[3]>999) {buf[3]-=1000; buf[4]++;} \
michael@0 682 (buf)[4]+=DPD2BIN[(sourml>>8)&0x3ff]; \
michael@0 683 if (buf[4]>999) {buf[4]-=1000; buf[5]++;} \
michael@0 684 (buf)[5]+=DPD2BIN[(sourml>>18)&0x3ff]; \
michael@0 685 if (buf[5]>999) {buf[5]-=1000; buf[6]++;} \
michael@0 686 sourmh=DFWORD(df, 1); \
michael@0 687 (buf)[6]+=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff]; \
michael@0 688 if (buf[6]>999) {buf[6]-=1000; buf[7]++;} \
michael@0 689 (buf)[7]+=DPD2BIN[(sourmh>>6)&0x3ff]; \
michael@0 690 if (buf[7]>999) {buf[7]-=1000; buf[8]++;} \
michael@0 691 (buf)[8]+=DPD2BIN[(sourmh>>16)&0x3ff]; \
michael@0 692 if (buf[8]>999) {buf[8]-=1000; buf[9]++;} \
michael@0 693 sourhi=DFWORD(df, 0); \
michael@0 694 (buf)[9]+=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff]; \
michael@0 695 if (buf[9]>999) {buf[9]-=1000; buf[10]++;} \
michael@0 696 (buf)[10]+=DPD2BIN[(sourhi>>4)&0x3ff]; \
michael@0 697 if (buf[10]>999) {buf[10]-=1000; buf[11]++;} \
michael@0 698 (buf)[11]+=DECCOMBMSD[sourhi>>26];}
michael@0 699 #endif
michael@0 700
michael@0 701
michael@0 702 /* Set a decFloat to the maximum positive finite number (Nmax) */
michael@0 703 #if DECPMAX==7
michael@0 704 #define DFSETNMAX(df) \
michael@0 705 {DFWORD(df, 0)=0x77f3fcff;}
michael@0 706 #elif DECPMAX==16
michael@0 707 #define DFSETNMAX(df) \
michael@0 708 {DFWORD(df, 0)=0x77fcff3f; \
michael@0 709 DFWORD(df, 1)=0xcff3fcff;}
michael@0 710 #elif DECPMAX==34
michael@0 711 #define DFSETNMAX(df) \
michael@0 712 {DFWORD(df, 0)=0x77ffcff3; \
michael@0 713 DFWORD(df, 1)=0xfcff3fcf; \
michael@0 714 DFWORD(df, 2)=0xf3fcff3f; \
michael@0 715 DFWORD(df, 3)=0xcff3fcff;}
michael@0 716 #endif
michael@0 717
michael@0 718 /* [end of format-dependent macros and constants] */
michael@0 719 #endif
michael@0 720
michael@0 721 #else
michael@0 722 #error decNumberLocal included more than once
michael@0 723 #endif

mercurial