intl/icu/source/i18n/decNumberLocal.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/decNumberLocal.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,723 @@
     1.4 +/* ------------------------------------------------------------------ */
     1.5 +/* decNumber package local type, tuning, and macro definitions        */
     1.6 +/* ------------------------------------------------------------------ */
     1.7 +/* Copyright (c) IBM Corporation, 2000-2012.   All rights reserved.   */
     1.8 +/*                                                                    */
     1.9 +/* This software is made available under the terms of the             */
    1.10 +/* ICU License -- ICU 1.8.1 and later.                                */
    1.11 +/*                                                                    */
    1.12 +/* The description and User's Guide ("The decNumber C Library") for   */
    1.13 +/* this software is called decNumber.pdf.  This document is           */
    1.14 +/* available, together with arithmetic and format specifications,     */
    1.15 +/* testcases, and Web links, on the General Decimal Arithmetic page.  */
    1.16 +/*                                                                    */
    1.17 +/* Please send comments, suggestions, and corrections to the author:  */
    1.18 +/*   mfc@uk.ibm.com                                                   */
    1.19 +/*   Mike Cowlishaw, IBM Fellow                                       */
    1.20 +/*   IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK         */
    1.21 +/* ------------------------------------------------------------------ */
    1.22 +/* This header file is included by all modules in the decNumber       */
    1.23 +/* library, and contains local type definitions, tuning parameters,   */
    1.24 +/* etc.  It should not need to be used by application programs.       */
    1.25 +/* decNumber.h or one of decDouble (etc.) must be included first.     */
    1.26 +/* ------------------------------------------------------------------ */
    1.27 +
    1.28 +#if !defined(DECNUMBERLOC)
    1.29 +  #define DECNUMBERLOC
    1.30 +  #define DECVERSION    "decNumber 3.61" /* Package Version [16 max.] */
    1.31 +  #define DECNLAUTHOR   "Mike Cowlishaw"              /* Who to blame */
    1.32 +
    1.33 +  #include <stdlib.h>         /* for abs                              */
    1.34 +  #include <string.h>         /* for memset, strcpy                   */
    1.35 +
    1.36 +  /* Conditional code flag -- set this to match hardware platform     */
    1.37 +  #if !defined(DECLITEND)
    1.38 +  #define DECLITEND 1         /* 1=little-endian, 0=big-endian        */
    1.39 +  #endif
    1.40 +
    1.41 +  /* Conditional code flag -- set this to 1 for best performance      */
    1.42 +  #if !defined(DECUSE64)
    1.43 +  #define DECUSE64  1         /* 1=use int64s, 0=int32 & smaller only */
    1.44 +  #endif
    1.45 +
    1.46 +  /* Conditional check flags -- set these to 0 for best performance   */
    1.47 +  #if !defined(DECCHECK)
    1.48 +  #define DECCHECK  0         /* 1 to enable robust checking          */
    1.49 +  #endif
    1.50 +  #if !defined(DECALLOC)
    1.51 +  #define DECALLOC  0         /* 1 to enable memory accounting        */
    1.52 +  #endif
    1.53 +  #if !defined(DECTRACE)
    1.54 +  #define DECTRACE  0         /* 1 to trace certain internals, etc.   */
    1.55 +  #endif
    1.56 +
    1.57 +  /* Tuning parameter for decNumber (arbitrary precision) module      */
    1.58 +  #if !defined(DECBUFFER)
    1.59 +  #define DECBUFFER 36        /* Size basis for local buffers.  This  */
    1.60 +                              /* should be a common maximum precision */
    1.61 +                              /* rounded up to a multiple of 4; must  */
    1.62 +                              /* be zero or positive.                 */
    1.63 +  #endif
    1.64 +
    1.65 +  /* ---------------------------------------------------------------- */
    1.66 +  /* Definitions for all modules (general-purpose)                    */
    1.67 +  /* ---------------------------------------------------------------- */
    1.68 +
    1.69 +  /* Local names for common types -- for safety, decNumber modules do */
    1.70 +  /* not use int or long directly.                                    */
    1.71 +  #define Flag   uint8_t
    1.72 +  #define Byte   int8_t
    1.73 +  #define uByte  uint8_t
    1.74 +  #define Short  int16_t
    1.75 +  #define uShort uint16_t
    1.76 +  #define Int    int32_t
    1.77 +  #define uInt   uint32_t
    1.78 +  #define Unit   decNumberUnit
    1.79 +  #if DECUSE64
    1.80 +  #define Long   int64_t
    1.81 +  #define uLong  uint64_t
    1.82 +  #endif
    1.83 +
    1.84 +  /* Development-use definitions                                      */
    1.85 +  typedef long int LI;        /* for printf arguments only            */
    1.86 +  #define DECNOINT  0         /* 1 to check no internal use of 'int'  */
    1.87 +                              /*   or stdint types                    */
    1.88 +  #if DECNOINT
    1.89 +    /* if these interfere with your C includes, do not set DECNOINT   */
    1.90 +    #define int     ?         /* enable to ensure that plain C 'int'  */
    1.91 +    #define long    ??        /* .. or 'long' types are not used      */
    1.92 +  #endif
    1.93 +
    1.94 +  /* LONGMUL32HI -- set w=(u*v)>>32, where w, u, and v are uInts      */
    1.95 +  /* (that is, sets w to be the high-order word of the 64-bit result; */
    1.96 +  /* the low-order word is simply u*v.)                               */
    1.97 +  /* This version is derived from Knuth via Hacker's Delight;         */
    1.98 +  /* it seems to optimize better than some others tried               */
    1.99 +  #define LONGMUL32HI(w, u, v) {             \
   1.100 +    uInt u0, u1, v0, v1, w0, w1, w2, t;      \
   1.101 +    u0=u & 0xffff; u1=u>>16;                 \
   1.102 +    v0=v & 0xffff; v1=v>>16;                 \
   1.103 +    w0=u0*v0;                                \
   1.104 +    t=u1*v0 + (w0>>16);                      \
   1.105 +    w1=t & 0xffff; w2=t>>16;                 \
   1.106 +    w1=u0*v1 + w1;                           \
   1.107 +    (w)=u1*v1 + w2 + (w1>>16);}
   1.108 +
   1.109 +  /* ROUNDUP -- round an integer up to a multiple of n                */
   1.110 +  #define ROUNDUP(i, n) ((((i)+(n)-1)/n)*n)
   1.111 +  #define ROUNDUP4(i)   (((i)+3)&~3)    /* special for n=4            */
   1.112 +
   1.113 +  /* ROUNDDOWN -- round an integer down to a multiple of n            */
   1.114 +  #define ROUNDDOWN(i, n) (((i)/n)*n)
   1.115 +  #define ROUNDDOWN4(i)   ((i)&~3)      /* special for n=4            */
   1.116 +
   1.117 +  /* References to multi-byte sequences under different sizes; these  */
   1.118 +  /* require locally declared variables, but do not violate strict    */
   1.119 +  /* aliasing or alignment (as did the UINTAT simple cast to uInt).   */
   1.120 +  /* Variables needed are uswork, uiwork, etc. [so do not use at same */
   1.121 +  /* level in an expression, e.g., UBTOUI(x)==UBTOUI(y) may fail].    */
   1.122 +
   1.123 +  /* Return a uInt, etc., from bytes starting at a char* or uByte*    */
   1.124 +  #define UBTOUS(b)  (memcpy((void *)&uswork, b, 2), uswork)
   1.125 +  #define UBTOUI(b)  (memcpy((void *)&uiwork, b, 4), uiwork)
   1.126 +
   1.127 +  /* Store a uInt, etc., into bytes starting at a char* or uByte*.    */
   1.128 +  /* Returns i, evaluated, for convenience; has to use uiwork because */
   1.129 +  /* i may be an expression.                                          */
   1.130 +  #define UBFROMUS(b, i)  (uswork=(i), memcpy(b, (void *)&uswork, 2), uswork)
   1.131 +  #define UBFROMUI(b, i)  (uiwork=(i), memcpy(b, (void *)&uiwork, 4), uiwork)
   1.132 +
   1.133 +  /* X10 and X100 -- multiply integer i by 10 or 100                  */
   1.134 +  /* [shifts are usually faster than multiply; could be conditional]  */
   1.135 +  #define X10(i)  (((i)<<1)+((i)<<3))
   1.136 +  #define X100(i) (((i)<<2)+((i)<<5)+((i)<<6))
   1.137 +
   1.138 +  /* MAXI and MINI -- general max & min (not in ANSI) for integers    */
   1.139 +  #define MAXI(x,y) ((x)<(y)?(y):(x))
   1.140 +  #define MINI(x,y) ((x)>(y)?(y):(x))
   1.141 +
   1.142 +  /* Useful constants                                                 */
   1.143 +  #define BILLION      1000000000            /* 10**9                 */
   1.144 +  /* CHARMASK: 0x30303030 for ASCII/UTF8; 0xF0F0F0F0 for EBCDIC       */
   1.145 +  #define CHARMASK ((((((((uInt)'0')<<8)+'0')<<8)+'0')<<8)+'0')
   1.146 +
   1.147 +
   1.148 +  /* ---------------------------------------------------------------- */
   1.149 +  /* Definitions for arbitary-precision modules (only valid after     */
   1.150 +  /* decNumber.h has been included)                                   */
   1.151 +  /* ---------------------------------------------------------------- */
   1.152 +
   1.153 +  /* Limits and constants                                             */
   1.154 +  #define DECNUMMAXP 999999999  /* maximum precision code can handle  */
   1.155 +  #define DECNUMMAXE 999999999  /* maximum adjusted exponent ditto    */
   1.156 +  #define DECNUMMINE -999999999 /* minimum adjusted exponent ditto    */
   1.157 +  #if (DECNUMMAXP != DEC_MAX_DIGITS)
   1.158 +    #error Maximum digits mismatch
   1.159 +  #endif
   1.160 +  #if (DECNUMMAXE != DEC_MAX_EMAX)
   1.161 +    #error Maximum exponent mismatch
   1.162 +  #endif
   1.163 +  #if (DECNUMMINE != DEC_MIN_EMIN)
   1.164 +    #error Minimum exponent mismatch
   1.165 +  #endif
   1.166 +
   1.167 +  /* Set DECDPUNMAX -- the maximum integer that fits in DECDPUN       */
   1.168 +  /* digits, and D2UTABLE -- the initializer for the D2U table        */
   1.169 +  #if   DECDPUN==1
   1.170 +    #define DECDPUNMAX 9
   1.171 +    #define D2UTABLE {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,  \
   1.172 +                      18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, \
   1.173 +                      33,34,35,36,37,38,39,40,41,42,43,44,45,46,47, \
   1.174 +                      48,49}
   1.175 +  #elif DECDPUN==2
   1.176 +    #define DECDPUNMAX 99
   1.177 +    #define D2UTABLE {0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,  \
   1.178 +                      11,11,12,12,13,13,14,14,15,15,16,16,17,17,18, \
   1.179 +                      18,19,19,20,20,21,21,22,22,23,23,24,24,25}
   1.180 +  #elif DECDPUN==3
   1.181 +    #define DECDPUNMAX 999
   1.182 +    #define D2UTABLE {0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,  \
   1.183 +                      8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13, \
   1.184 +                      13,14,14,14,15,15,15,16,16,16,17}
   1.185 +  #elif DECDPUN==4
   1.186 +    #define DECDPUNMAX 9999
   1.187 +    #define D2UTABLE {0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,  \
   1.188 +                      6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11, \
   1.189 +                      11,11,11,12,12,12,12,13}
   1.190 +  #elif DECDPUN==5
   1.191 +    #define DECDPUNMAX 99999
   1.192 +    #define D2UTABLE {0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,  \
   1.193 +                      5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,  \
   1.194 +                      9,9,10,10,10,10}
   1.195 +  #elif DECDPUN==6
   1.196 +    #define DECDPUNMAX 999999
   1.197 +    #define D2UTABLE {0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4,  \
   1.198 +                      4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8,  \
   1.199 +                      8,8,8,8,8,9}
   1.200 +  #elif DECDPUN==7
   1.201 +    #define DECDPUNMAX 9999999
   1.202 +    #define D2UTABLE {0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,  \
   1.203 +                      4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7,  \
   1.204 +                      7,7,7,7,7,7}
   1.205 +  #elif DECDPUN==8
   1.206 +    #define DECDPUNMAX 99999999
   1.207 +    #define D2UTABLE {0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,  \
   1.208 +                      3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,  \
   1.209 +                      6,6,6,6,6,7}
   1.210 +  #elif DECDPUN==9
   1.211 +    #define DECDPUNMAX 999999999
   1.212 +    #define D2UTABLE {0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3,  \
   1.213 +                      3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,  \
   1.214 +                      5,5,6,6,6,6}
   1.215 +  #elif defined(DECDPUN)
   1.216 +    #error DECDPUN must be in the range 1-9
   1.217 +  #endif
   1.218 +
   1.219 +  /* ----- Shared data (in decNumber.c) ----- */
   1.220 +  /* Public lookup table used by the D2U macro (see below)            */
   1.221 +  #define DECMAXD2U 49
   1.222 +  /*extern const uByte d2utable[DECMAXD2U+1];*/
   1.223 +
   1.224 +  /* ----- Macros ----- */
   1.225 +  /* ISZERO -- return true if decNumber dn is a zero                  */
   1.226 +  /* [performance-critical in some situations]                        */
   1.227 +  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
   1.228 +
   1.229 +  /* D2U -- return the number of Units needed to hold d digits        */
   1.230 +  /* (runtime version, with table lookaside for small d)              */
   1.231 +  #if DECDPUN==8
   1.232 +    #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+7)>>3))
   1.233 +  #elif DECDPUN==4
   1.234 +    #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+3)>>2))
   1.235 +  #else
   1.236 +    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
   1.237 +  #endif
   1.238 +  /* SD2U -- static D2U macro (for compile-time calculation)          */
   1.239 +  #define SD2U(d) (((d)+DECDPUN-1)/DECDPUN)
   1.240 +
   1.241 +  /* MSUDIGITS -- returns digits in msu, from digits, calculated      */
   1.242 +  /* using D2U                                                        */
   1.243 +  #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
   1.244 +
   1.245 +  /* D2N -- return the number of decNumber structs that would be      */
   1.246 +  /* needed to contain that number of digits (and the initial         */
   1.247 +  /* decNumber struct) safely.  Note that one Unit is included in the */
   1.248 +  /* initial structure.  Used for allocating space that is aligned on */
   1.249 +  /* a decNumber struct boundary. */
   1.250 +  #define D2N(d) \
   1.251 +    ((((SD2U(d)-1)*sizeof(Unit))+sizeof(decNumber)*2-1)/sizeof(decNumber))
   1.252 +
   1.253 +  /* TODIGIT -- macro to remove the leading digit from the unsigned   */
   1.254 +  /* integer u at column cut (counting from the right, LSD=0) and     */
   1.255 +  /* place it as an ASCII character into the character pointed to by  */
   1.256 +  /* c.  Note that cut must be <= 9, and the maximum value for u is   */
   1.257 +  /* 2,000,000,000 (as is needed for negative exponents of            */
   1.258 +  /* subnormals).  The unsigned integer pow is used as a temporary    */
   1.259 +  /* variable. */
   1.260 +  #define TODIGIT(u, cut, c, pow) {       \
   1.261 +    *(c)='0';                             \
   1.262 +    pow=DECPOWERS[cut]*2;                 \
   1.263 +    if ((u)>pow) {                        \
   1.264 +      pow*=4;                             \
   1.265 +      if ((u)>=pow) {(u)-=pow; *(c)+=8;}  \
   1.266 +      pow/=2;                             \
   1.267 +      if ((u)>=pow) {(u)-=pow; *(c)+=4;}  \
   1.268 +      pow/=2;                             \
   1.269 +      }                                   \
   1.270 +    if ((u)>=pow) {(u)-=pow; *(c)+=2;}    \
   1.271 +    pow/=2;                               \
   1.272 +    if ((u)>=pow) {(u)-=pow; *(c)+=1;}    \
   1.273 +    }
   1.274 +
   1.275 +  /* ---------------------------------------------------------------- */
   1.276 +  /* Definitions for fixed-precision modules (only valid after        */
   1.277 +  /* decSingle.h, decDouble.h, or decQuad.h has been included)        */
   1.278 +  /* ---------------------------------------------------------------- */
   1.279 +
   1.280 +  /* bcdnum -- a structure describing a format-independent finite     */
   1.281 +  /* number, whose coefficient is a string of bcd8 uBytes             */
   1.282 +  typedef struct {
   1.283 +    uByte   *msd;             /* -> most significant digit            */
   1.284 +    uByte   *lsd;             /* -> least ditto                       */
   1.285 +    uInt     sign;            /* 0=positive, DECFLOAT_Sign=negative   */
   1.286 +    Int      exponent;        /* Unadjusted signed exponent (q), or   */
   1.287 +                              /* DECFLOAT_NaN etc. for a special      */
   1.288 +    } bcdnum;
   1.289 +
   1.290 +  /* Test if exponent or bcdnum exponent must be a special, etc.      */
   1.291 +  #define EXPISSPECIAL(exp) ((exp)>=DECFLOAT_MinSp)
   1.292 +  #define EXPISINF(exp) (exp==DECFLOAT_Inf)
   1.293 +  #define EXPISNAN(exp) (exp==DECFLOAT_qNaN || exp==DECFLOAT_sNaN)
   1.294 +  #define NUMISSPECIAL(num) (EXPISSPECIAL((num)->exponent))
   1.295 +
   1.296 +  /* Refer to a 32-bit word or byte in a decFloat (df) by big-endian  */
   1.297 +  /* (array) notation (the 0 word or byte contains the sign bit),     */
   1.298 +  /* automatically adjusting for endianness; similarly address a word */
   1.299 +  /* in the next-wider format (decFloatWider, or dfw)                 */
   1.300 +  #define DECWORDS  (DECBYTES/4)
   1.301 +  #define DECWWORDS (DECWBYTES/4)
   1.302 +  #if DECLITEND
   1.303 +    #define DFBYTE(df, off)   ((df)->bytes[DECBYTES-1-(off)])
   1.304 +    #define DFWORD(df, off)   ((df)->words[DECWORDS-1-(off)])
   1.305 +    #define DFWWORD(dfw, off) ((dfw)->words[DECWWORDS-1-(off)])
   1.306 +  #else
   1.307 +    #define DFBYTE(df, off)   ((df)->bytes[off])
   1.308 +    #define DFWORD(df, off)   ((df)->words[off])
   1.309 +    #define DFWWORD(dfw, off) ((dfw)->words[off])
   1.310 +  #endif
   1.311 +
   1.312 +  /* Tests for sign or specials, directly on DECFLOATs                */
   1.313 +  #define DFISSIGNED(df)   (DFWORD(df, 0)&0x80000000)
   1.314 +  #define DFISSPECIAL(df) ((DFWORD(df, 0)&0x78000000)==0x78000000)
   1.315 +  #define DFISINF(df)     ((DFWORD(df, 0)&0x7c000000)==0x78000000)
   1.316 +  #define DFISNAN(df)     ((DFWORD(df, 0)&0x7c000000)==0x7c000000)
   1.317 +  #define DFISQNAN(df)    ((DFWORD(df, 0)&0x7e000000)==0x7c000000)
   1.318 +  #define DFISSNAN(df)    ((DFWORD(df, 0)&0x7e000000)==0x7e000000)
   1.319 +
   1.320 +  /* Shared lookup tables                                             */
   1.321 +  extern const uInt   DECCOMBMSD[64];   /* Combination field -> MSD   */
   1.322 +  extern const uInt   DECCOMBFROM[48];  /* exp+msd -> Combination     */
   1.323 +
   1.324 +  /* Private generic (utility) routine                                */
   1.325 +  #if DECCHECK || DECTRACE
   1.326 +    extern void decShowNum(const bcdnum *, const char *);
   1.327 +  #endif
   1.328 +
   1.329 +  /* Format-dependent macros and constants                            */
   1.330 +  #if defined(DECPMAX)
   1.331 +
   1.332 +    /* Useful constants                                               */
   1.333 +    #define DECPMAX9  (ROUNDUP(DECPMAX, 9)/9)  /* 'Pmax' in 10**9s    */
   1.334 +    /* Top words for a zero                                           */
   1.335 +    #define SINGLEZERO   0x22500000
   1.336 +    #define DOUBLEZERO   0x22380000
   1.337 +    #define QUADZERO     0x22080000
   1.338 +    /* [ZEROWORD is defined to be one of these in the DFISZERO macro] */
   1.339 +
   1.340 +    /* Format-dependent common tests:                                 */
   1.341 +    /*   DFISZERO   -- test for (any) zero                            */
   1.342 +    /*   DFISCCZERO -- test for coefficient continuation being zero   */
   1.343 +    /*   DFISCC01   -- test for coefficient contains only 0s and 1s   */
   1.344 +    /*   DFISINT    -- test for finite and exponent q=0               */
   1.345 +    /*   DFISUINT01 -- test for sign=0, finite, exponent q=0, and     */
   1.346 +    /*                 MSD=0 or 1                                     */
   1.347 +    /*   ZEROWORD is also defined here.                               */
   1.348 +    /* In DFISZERO the first test checks the least-significant word   */
   1.349 +    /* (most likely to be non-zero); the penultimate tests MSD and    */
   1.350 +    /* DPDs in the signword, and the final test excludes specials and */
   1.351 +    /* MSD>7.  DFISINT similarly has to allow for the two forms of    */
   1.352 +    /* MSD codes.  DFISUINT01 only has to allow for one form of MSD   */
   1.353 +    /* code.                                                          */
   1.354 +    #if DECPMAX==7
   1.355 +      #define ZEROWORD SINGLEZERO
   1.356 +      /* [test macros not needed except for Zero]                     */
   1.357 +      #define DFISZERO(df)  ((DFWORD(df, 0)&0x1c0fffff)==0         \
   1.358 +                          && (DFWORD(df, 0)&0x60000000)!=0x60000000)
   1.359 +    #elif DECPMAX==16
   1.360 +      #define ZEROWORD DOUBLEZERO
   1.361 +      #define DFISZERO(df)  ((DFWORD(df, 1)==0                     \
   1.362 +                          && (DFWORD(df, 0)&0x1c03ffff)==0         \
   1.363 +                          && (DFWORD(df, 0)&0x60000000)!=0x60000000))
   1.364 +      #define DFISINT(df) ((DFWORD(df, 0)&0x63fc0000)==0x22380000  \
   1.365 +                         ||(DFWORD(df, 0)&0x7bfc0000)==0x6a380000)
   1.366 +      #define DFISUINT01(df) ((DFWORD(df, 0)&0xfbfc0000)==0x22380000)
   1.367 +      #define DFISCCZERO(df) (DFWORD(df, 1)==0                     \
   1.368 +                          && (DFWORD(df, 0)&0x0003ffff)==0)
   1.369 +      #define DFISCC01(df)  ((DFWORD(df, 0)&~0xfffc9124)==0        \
   1.370 +                          && (DFWORD(df, 1)&~0x49124491)==0)
   1.371 +    #elif DECPMAX==34
   1.372 +      #define ZEROWORD QUADZERO
   1.373 +      #define DFISZERO(df)  ((DFWORD(df, 3)==0                     \
   1.374 +                          &&  DFWORD(df, 2)==0                     \
   1.375 +                          &&  DFWORD(df, 1)==0                     \
   1.376 +                          && (DFWORD(df, 0)&0x1c003fff)==0         \
   1.377 +                          && (DFWORD(df, 0)&0x60000000)!=0x60000000))
   1.378 +      #define DFISINT(df) ((DFWORD(df, 0)&0x63ffc000)==0x22080000  \
   1.379 +                         ||(DFWORD(df, 0)&0x7bffc000)==0x6a080000)
   1.380 +      #define DFISUINT01(df) ((DFWORD(df, 0)&0xfbffc000)==0x22080000)
   1.381 +      #define DFISCCZERO(df) (DFWORD(df, 3)==0                     \
   1.382 +                          &&  DFWORD(df, 2)==0                     \
   1.383 +                          &&  DFWORD(df, 1)==0                     \
   1.384 +                          && (DFWORD(df, 0)&0x00003fff)==0)
   1.385 +
   1.386 +      #define DFISCC01(df)   ((DFWORD(df, 0)&~0xffffc912)==0       \
   1.387 +                          &&  (DFWORD(df, 1)&~0x44912449)==0       \
   1.388 +                          &&  (DFWORD(df, 2)&~0x12449124)==0       \
   1.389 +                          &&  (DFWORD(df, 3)&~0x49124491)==0)
   1.390 +    #endif
   1.391 +
   1.392 +    /* Macros to test if a certain 10 bits of a uInt or pair of uInts */
   1.393 +    /* are a canonical declet [higher or lower bits are ignored].     */
   1.394 +    /* declet is at offset 0 (from the right) in a uInt:              */
   1.395 +    #define CANONDPD(dpd) (((dpd)&0x300)==0 || ((dpd)&0x6e)!=0x6e)
   1.396 +    /* declet is at offset k (a multiple of 2) in a uInt:             */
   1.397 +    #define CANONDPDOFF(dpd, k) (((dpd)&(0x300<<(k)))==0            \
   1.398 +      || ((dpd)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k)))
   1.399 +    /* declet is at offset k (a multiple of 2) in a pair of uInts:    */
   1.400 +    /* [the top 2 bits will always be in the more-significant uInt]   */
   1.401 +    #define CANONDPDTWO(hi, lo, k) (((hi)&(0x300>>(32-(k))))==0     \
   1.402 +      || ((hi)&(0x6e>>(32-(k))))!=(0x6e>>(32-(k)))                  \
   1.403 +      || ((lo)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k)))
   1.404 +
   1.405 +    /* Macro to test whether a full-length (length DECPMAX) BCD8      */
   1.406 +    /* coefficient, starting at uByte u, is all zeros                 */
   1.407 +    /* Test just the LSWord first, then the remainder as a sequence   */
   1.408 +    /* of tests in order to avoid same-level use of UBTOUI            */
   1.409 +    #if DECPMAX==7
   1.410 +      #define ISCOEFFZERO(u) (                                      \
   1.411 +           UBTOUI((u)+DECPMAX-4)==0                                 \
   1.412 +        && UBTOUS((u)+DECPMAX-6)==0                                 \
   1.413 +        && *(u)==0)
   1.414 +    #elif DECPMAX==16
   1.415 +      #define ISCOEFFZERO(u) (                                      \
   1.416 +           UBTOUI((u)+DECPMAX-4)==0                                 \
   1.417 +        && UBTOUI((u)+DECPMAX-8)==0                                 \
   1.418 +        && UBTOUI((u)+DECPMAX-12)==0                                \
   1.419 +        && UBTOUI(u)==0)
   1.420 +    #elif DECPMAX==34
   1.421 +      #define ISCOEFFZERO(u) (                                      \
   1.422 +           UBTOUI((u)+DECPMAX-4)==0                                 \
   1.423 +        && UBTOUI((u)+DECPMAX-8)==0                                 \
   1.424 +        && UBTOUI((u)+DECPMAX-12)==0                                \
   1.425 +        && UBTOUI((u)+DECPMAX-16)==0                                \
   1.426 +        && UBTOUI((u)+DECPMAX-20)==0                                \
   1.427 +        && UBTOUI((u)+DECPMAX-24)==0                                \
   1.428 +        && UBTOUI((u)+DECPMAX-28)==0                                \
   1.429 +        && UBTOUI((u)+DECPMAX-32)==0                                \
   1.430 +        && UBTOUS(u)==0)
   1.431 +    #endif
   1.432 +
   1.433 +    /* Macros and masks for the exponent continuation field and MSD   */
   1.434 +    /* Get the exponent continuation from a decFloat *df as an Int    */
   1.435 +    #define GETECON(df) ((Int)((DFWORD((df), 0)&0x03ffffff)>>(32-6-DECECONL)))
   1.436 +    /* Ditto, from the next-wider format                              */
   1.437 +    #define GETWECON(df) ((Int)((DFWWORD((df), 0)&0x03ffffff)>>(32-6-DECWECONL)))
   1.438 +    /* Get the biased exponent similarly                              */
   1.439 +    #define GETEXP(df)  ((Int)(DECCOMBEXP[DFWORD((df), 0)>>26]+GETECON(df)))
   1.440 +    /* Get the unbiased exponent similarly                            */
   1.441 +    #define GETEXPUN(df) ((Int)GETEXP(df)-DECBIAS)
   1.442 +    /* Get the MSD similarly (as uInt)                                */
   1.443 +    #define GETMSD(df)   (DECCOMBMSD[DFWORD((df), 0)>>26])
   1.444 +
   1.445 +    /* Compile-time computes of the exponent continuation field masks */
   1.446 +    /* full exponent continuation field:                              */
   1.447 +    #define ECONMASK ((0x03ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))
   1.448 +    /* same, not including its first digit (the qNaN/sNaN selector):  */
   1.449 +    #define ECONNANMASK ((0x01ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))
   1.450 +
   1.451 +    /* Macros to decode the coefficient in a finite decFloat *df into */
   1.452 +    /* a BCD string (uByte *bcdin) of length DECPMAX uBytes.          */
   1.453 +
   1.454 +    /* In-line sequence to convert least significant 10 bits of uInt  */
   1.455 +    /* dpd to three BCD8 digits starting at uByte u.  Note that an    */
   1.456 +    /* extra byte is written to the right of the three digits because */
   1.457 +    /* four bytes are moved at a time for speed; the alternative      */
   1.458 +    /* macro moves exactly three bytes (usually slower).              */
   1.459 +    #define dpd2bcd8(u, dpd)  memcpy(u, &DPD2BCD8[((dpd)&0x3ff)*4], 4)
   1.460 +    #define dpd2bcd83(u, dpd) memcpy(u, &DPD2BCD8[((dpd)&0x3ff)*4], 3)
   1.461 +
   1.462 +    /* Decode the declets.  After extracting each one, it is decoded  */
   1.463 +    /* to BCD8 using a table lookup (also used for variable-length    */
   1.464 +    /* decode).  Each DPD decode is 3 bytes BCD8 plus a one-byte      */
   1.465 +    /* length which is not used, here).  Fixed-length 4-byte moves    */
   1.466 +    /* are fast, however, almost everywhere, and so are used except   */
   1.467 +    /* for the final three bytes (to avoid overrun).  The code below  */
   1.468 +    /* is 36 instructions for Doubles and about 70 for Quads, even    */
   1.469 +    /* on IA32.                                                       */
   1.470 +
   1.471 +    /* Two macros are defined for each format:                        */
   1.472 +    /*   GETCOEFF extracts the coefficient of the current format      */
   1.473 +    /*   GETWCOEFF extracts the coefficient of the next-wider format. */
   1.474 +    /* The latter is a copy of the next-wider GETCOEFF using DFWWORD. */
   1.475 +
   1.476 +    #if DECPMAX==7
   1.477 +    #define GETCOEFF(df, bcd) {                          \
   1.478 +      uInt sourhi=DFWORD(df, 0);                         \
   1.479 +      *(bcd)=(uByte)DECCOMBMSD[sourhi>>26];              \
   1.480 +      dpd2bcd8(bcd+1, sourhi>>10);                       \
   1.481 +      dpd2bcd83(bcd+4, sourhi);}
   1.482 +    #define GETWCOEFF(df, bcd) {                         \
   1.483 +      uInt sourhi=DFWWORD(df, 0);                        \
   1.484 +      uInt sourlo=DFWWORD(df, 1);                        \
   1.485 +      *(bcd)=(uByte)DECCOMBMSD[sourhi>>26];              \
   1.486 +      dpd2bcd8(bcd+1, sourhi>>8);                        \
   1.487 +      dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30));       \
   1.488 +      dpd2bcd8(bcd+7, sourlo>>20);                       \
   1.489 +      dpd2bcd8(bcd+10, sourlo>>10);                      \
   1.490 +      dpd2bcd83(bcd+13, sourlo);}
   1.491 +
   1.492 +    #elif DECPMAX==16
   1.493 +    #define GETCOEFF(df, bcd) {                          \
   1.494 +      uInt sourhi=DFWORD(df, 0);                         \
   1.495 +      uInt sourlo=DFWORD(df, 1);                         \
   1.496 +      *(bcd)=(uByte)DECCOMBMSD[sourhi>>26];              \
   1.497 +      dpd2bcd8(bcd+1, sourhi>>8);                        \
   1.498 +      dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30));       \
   1.499 +      dpd2bcd8(bcd+7, sourlo>>20);                       \
   1.500 +      dpd2bcd8(bcd+10, sourlo>>10);                      \
   1.501 +      dpd2bcd83(bcd+13, sourlo);}
   1.502 +    #define GETWCOEFF(df, bcd) {                         \
   1.503 +      uInt sourhi=DFWWORD(df, 0);                        \
   1.504 +      uInt sourmh=DFWWORD(df, 1);                        \
   1.505 +      uInt sourml=DFWWORD(df, 2);                        \
   1.506 +      uInt sourlo=DFWWORD(df, 3);                        \
   1.507 +      *(bcd)=(uByte)DECCOMBMSD[sourhi>>26];              \
   1.508 +      dpd2bcd8(bcd+1, sourhi>>4);                        \
   1.509 +      dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26));     \
   1.510 +      dpd2bcd8(bcd+7, sourmh>>16);                       \
   1.511 +      dpd2bcd8(bcd+10, sourmh>>6);                       \
   1.512 +      dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28));    \
   1.513 +      dpd2bcd8(bcd+16, sourml>>18);                      \
   1.514 +      dpd2bcd8(bcd+19, sourml>>8);                       \
   1.515 +      dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30));    \
   1.516 +      dpd2bcd8(bcd+25, sourlo>>20);                      \
   1.517 +      dpd2bcd8(bcd+28, sourlo>>10);                      \
   1.518 +      dpd2bcd83(bcd+31, sourlo);}
   1.519 +
   1.520 +    #elif DECPMAX==34
   1.521 +    #define GETCOEFF(df, bcd) {                          \
   1.522 +      uInt sourhi=DFWORD(df, 0);                         \
   1.523 +      uInt sourmh=DFWORD(df, 1);                         \
   1.524 +      uInt sourml=DFWORD(df, 2);                         \
   1.525 +      uInt sourlo=DFWORD(df, 3);                         \
   1.526 +      *(bcd)=(uByte)DECCOMBMSD[sourhi>>26];              \
   1.527 +      dpd2bcd8(bcd+1, sourhi>>4);                        \
   1.528 +      dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26));     \
   1.529 +      dpd2bcd8(bcd+7, sourmh>>16);                       \
   1.530 +      dpd2bcd8(bcd+10, sourmh>>6);                       \
   1.531 +      dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28));    \
   1.532 +      dpd2bcd8(bcd+16, sourml>>18);                      \
   1.533 +      dpd2bcd8(bcd+19, sourml>>8);                       \
   1.534 +      dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30));    \
   1.535 +      dpd2bcd8(bcd+25, sourlo>>20);                      \
   1.536 +      dpd2bcd8(bcd+28, sourlo>>10);                      \
   1.537 +      dpd2bcd83(bcd+31, sourlo);}
   1.538 +
   1.539 +      #define GETWCOEFF(df, bcd) {??} /* [should never be used]       */
   1.540 +    #endif
   1.541 +
   1.542 +    /* Macros to decode the coefficient in a finite decFloat *df into */
   1.543 +    /* a base-billion uInt array, with the least-significant          */
   1.544 +    /* 0-999999999 'digit' at offset 0.                               */
   1.545 +
   1.546 +    /* Decode the declets.  After extracting each one, it is decoded  */
   1.547 +    /* to binary using a table lookup.  Three tables are used; one    */
   1.548 +    /* the usual DPD to binary, the other two pre-multiplied by 1000  */
   1.549 +    /* and 1000000 to avoid multiplication during decode.  These      */
   1.550 +    /* tables can also be used for multiplying up the MSD as the DPD  */
   1.551 +    /* code for 0 through 9 is the identity.                          */
   1.552 +    #define DPD2BIN0 DPD2BIN         /* for prettier code             */
   1.553 +
   1.554 +    #if DECPMAX==7
   1.555 +    #define GETCOEFFBILL(df, buf) {                           \
   1.556 +      uInt sourhi=DFWORD(df, 0);                              \
   1.557 +      (buf)[0]=DPD2BIN0[sourhi&0x3ff]                         \
   1.558 +              +DPD2BINK[(sourhi>>10)&0x3ff]                   \
   1.559 +              +DPD2BINM[DECCOMBMSD[sourhi>>26]];}
   1.560 +
   1.561 +    #elif DECPMAX==16
   1.562 +    #define GETCOEFFBILL(df, buf) {                           \
   1.563 +      uInt sourhi, sourlo;                                    \
   1.564 +      sourlo=DFWORD(df, 1);                                   \
   1.565 +      (buf)[0]=DPD2BIN0[sourlo&0x3ff]                         \
   1.566 +              +DPD2BINK[(sourlo>>10)&0x3ff]                   \
   1.567 +              +DPD2BINM[(sourlo>>20)&0x3ff];                  \
   1.568 +      sourhi=DFWORD(df, 0);                                   \
   1.569 +      (buf)[1]=DPD2BIN0[((sourhi<<2) | (sourlo>>30))&0x3ff]   \
   1.570 +              +DPD2BINK[(sourhi>>8)&0x3ff]                    \
   1.571 +              +DPD2BINM[DECCOMBMSD[sourhi>>26]];}
   1.572 +
   1.573 +    #elif DECPMAX==34
   1.574 +    #define GETCOEFFBILL(df, buf) {                           \
   1.575 +      uInt sourhi, sourmh, sourml, sourlo;                    \
   1.576 +      sourlo=DFWORD(df, 3);                                   \
   1.577 +      (buf)[0]=DPD2BIN0[sourlo&0x3ff]                         \
   1.578 +              +DPD2BINK[(sourlo>>10)&0x3ff]                   \
   1.579 +              +DPD2BINM[(sourlo>>20)&0x3ff];                  \
   1.580 +      sourml=DFWORD(df, 2);                                   \
   1.581 +      (buf)[1]=DPD2BIN0[((sourml<<2) | (sourlo>>30))&0x3ff]   \
   1.582 +              +DPD2BINK[(sourml>>8)&0x3ff]                    \
   1.583 +              +DPD2BINM[(sourml>>18)&0x3ff];                  \
   1.584 +      sourmh=DFWORD(df, 1);                                   \
   1.585 +      (buf)[2]=DPD2BIN0[((sourmh<<4) | (sourml>>28))&0x3ff]   \
   1.586 +              +DPD2BINK[(sourmh>>6)&0x3ff]                    \
   1.587 +              +DPD2BINM[(sourmh>>16)&0x3ff];                  \
   1.588 +      sourhi=DFWORD(df, 0);                                   \
   1.589 +      (buf)[3]=DPD2BIN0[((sourhi<<6) | (sourmh>>26))&0x3ff]   \
   1.590 +              +DPD2BINK[(sourhi>>4)&0x3ff]                    \
   1.591 +              +DPD2BINM[DECCOMBMSD[sourhi>>26]];}
   1.592 +
   1.593 +    #endif
   1.594 +
   1.595 +    /* Macros to decode the coefficient in a finite decFloat *df into */
   1.596 +    /* a base-thousand uInt array (of size DECLETS+1, to allow for    */
   1.597 +    /* the MSD), with the least-significant 0-999 'digit' at offset 0.*/
   1.598 +
   1.599 +    /* Decode the declets.  After extracting each one, it is decoded  */
   1.600 +    /* to binary using a table lookup.                                */
   1.601 +    #if DECPMAX==7
   1.602 +    #define GETCOEFFTHOU(df, buf) {                           \
   1.603 +      uInt sourhi=DFWORD(df, 0);                              \
   1.604 +      (buf)[0]=DPD2BIN[sourhi&0x3ff];                         \
   1.605 +      (buf)[1]=DPD2BIN[(sourhi>>10)&0x3ff];                   \
   1.606 +      (buf)[2]=DECCOMBMSD[sourhi>>26];}
   1.607 +
   1.608 +    #elif DECPMAX==16
   1.609 +    #define GETCOEFFTHOU(df, buf) {                           \
   1.610 +      uInt sourhi, sourlo;                                    \
   1.611 +      sourlo=DFWORD(df, 1);                                   \
   1.612 +      (buf)[0]=DPD2BIN[sourlo&0x3ff];                         \
   1.613 +      (buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff];                   \
   1.614 +      (buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff];                   \
   1.615 +      sourhi=DFWORD(df, 0);                                   \
   1.616 +      (buf)[3]=DPD2BIN[((sourhi<<2) | (sourlo>>30))&0x3ff];   \
   1.617 +      (buf)[4]=DPD2BIN[(sourhi>>8)&0x3ff];                    \
   1.618 +      (buf)[5]=DECCOMBMSD[sourhi>>26];}
   1.619 +
   1.620 +    #elif DECPMAX==34
   1.621 +    #define GETCOEFFTHOU(df, buf) {                           \
   1.622 +      uInt sourhi, sourmh, sourml, sourlo;                    \
   1.623 +      sourlo=DFWORD(df, 3);                                   \
   1.624 +      (buf)[0]=DPD2BIN[sourlo&0x3ff];                         \
   1.625 +      (buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff];                   \
   1.626 +      (buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff];                   \
   1.627 +      sourml=DFWORD(df, 2);                                   \
   1.628 +      (buf)[3]=DPD2BIN[((sourml<<2) | (sourlo>>30))&0x3ff];   \
   1.629 +      (buf)[4]=DPD2BIN[(sourml>>8)&0x3ff];                    \
   1.630 +      (buf)[5]=DPD2BIN[(sourml>>18)&0x3ff];                   \
   1.631 +      sourmh=DFWORD(df, 1);                                   \
   1.632 +      (buf)[6]=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff];   \
   1.633 +      (buf)[7]=DPD2BIN[(sourmh>>6)&0x3ff];                    \
   1.634 +      (buf)[8]=DPD2BIN[(sourmh>>16)&0x3ff];                   \
   1.635 +      sourhi=DFWORD(df, 0);                                   \
   1.636 +      (buf)[9]=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff];   \
   1.637 +      (buf)[10]=DPD2BIN[(sourhi>>4)&0x3ff];                   \
   1.638 +      (buf)[11]=DECCOMBMSD[sourhi>>26];}
   1.639 +    #endif
   1.640 +
   1.641 +
   1.642 +    /* Macros to decode the coefficient in a finite decFloat *df and  */
   1.643 +    /* add to a base-thousand uInt array (as for GETCOEFFTHOU).       */
   1.644 +    /* After the addition then most significant 'digit' in the array  */
   1.645 +    /* might have a value larger then 10 (with a maximum of 19).      */
   1.646 +    #if DECPMAX==7
   1.647 +    #define ADDCOEFFTHOU(df, buf) {                           \
   1.648 +      uInt sourhi=DFWORD(df, 0);                              \
   1.649 +      (buf)[0]+=DPD2BIN[sourhi&0x3ff];                        \
   1.650 +      if (buf[0]>999) {buf[0]-=1000; buf[1]++;}               \
   1.651 +      (buf)[1]+=DPD2BIN[(sourhi>>10)&0x3ff];                  \
   1.652 +      if (buf[1]>999) {buf[1]-=1000; buf[2]++;}               \
   1.653 +      (buf)[2]+=DECCOMBMSD[sourhi>>26];}
   1.654 +
   1.655 +    #elif DECPMAX==16
   1.656 +    #define ADDCOEFFTHOU(df, buf) {                           \
   1.657 +      uInt sourhi, sourlo;                                    \
   1.658 +      sourlo=DFWORD(df, 1);                                   \
   1.659 +      (buf)[0]+=DPD2BIN[sourlo&0x3ff];                        \
   1.660 +      if (buf[0]>999) {buf[0]-=1000; buf[1]++;}               \
   1.661 +      (buf)[1]+=DPD2BIN[(sourlo>>10)&0x3ff];                  \
   1.662 +      if (buf[1]>999) {buf[1]-=1000; buf[2]++;}               \
   1.663 +      (buf)[2]+=DPD2BIN[(sourlo>>20)&0x3ff];                  \
   1.664 +      if (buf[2]>999) {buf[2]-=1000; buf[3]++;}               \
   1.665 +      sourhi=DFWORD(df, 0);                                   \
   1.666 +      (buf)[3]+=DPD2BIN[((sourhi<<2) | (sourlo>>30))&0x3ff];  \
   1.667 +      if (buf[3]>999) {buf[3]-=1000; buf[4]++;}               \
   1.668 +      (buf)[4]+=DPD2BIN[(sourhi>>8)&0x3ff];                   \
   1.669 +      if (buf[4]>999) {buf[4]-=1000; buf[5]++;}               \
   1.670 +      (buf)[5]+=DECCOMBMSD[sourhi>>26];}
   1.671 +
   1.672 +    #elif DECPMAX==34
   1.673 +    #define ADDCOEFFTHOU(df, buf) {                           \
   1.674 +      uInt sourhi, sourmh, sourml, sourlo;                    \
   1.675 +      sourlo=DFWORD(df, 3);                                   \
   1.676 +      (buf)[0]+=DPD2BIN[sourlo&0x3ff];                        \
   1.677 +      if (buf[0]>999) {buf[0]-=1000; buf[1]++;}               \
   1.678 +      (buf)[1]+=DPD2BIN[(sourlo>>10)&0x3ff];                  \
   1.679 +      if (buf[1]>999) {buf[1]-=1000; buf[2]++;}               \
   1.680 +      (buf)[2]+=DPD2BIN[(sourlo>>20)&0x3ff];                  \
   1.681 +      if (buf[2]>999) {buf[2]-=1000; buf[3]++;}               \
   1.682 +      sourml=DFWORD(df, 2);                                   \
   1.683 +      (buf)[3]+=DPD2BIN[((sourml<<2) | (sourlo>>30))&0x3ff];  \
   1.684 +      if (buf[3]>999) {buf[3]-=1000; buf[4]++;}               \
   1.685 +      (buf)[4]+=DPD2BIN[(sourml>>8)&0x3ff];                   \
   1.686 +      if (buf[4]>999) {buf[4]-=1000; buf[5]++;}               \
   1.687 +      (buf)[5]+=DPD2BIN[(sourml>>18)&0x3ff];                  \
   1.688 +      if (buf[5]>999) {buf[5]-=1000; buf[6]++;}               \
   1.689 +      sourmh=DFWORD(df, 1);                                   \
   1.690 +      (buf)[6]+=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff];  \
   1.691 +      if (buf[6]>999) {buf[6]-=1000; buf[7]++;}               \
   1.692 +      (buf)[7]+=DPD2BIN[(sourmh>>6)&0x3ff];                   \
   1.693 +      if (buf[7]>999) {buf[7]-=1000; buf[8]++;}               \
   1.694 +      (buf)[8]+=DPD2BIN[(sourmh>>16)&0x3ff];                  \
   1.695 +      if (buf[8]>999) {buf[8]-=1000; buf[9]++;}               \
   1.696 +      sourhi=DFWORD(df, 0);                                   \
   1.697 +      (buf)[9]+=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff];  \
   1.698 +      if (buf[9]>999) {buf[9]-=1000; buf[10]++;}              \
   1.699 +      (buf)[10]+=DPD2BIN[(sourhi>>4)&0x3ff];                  \
   1.700 +      if (buf[10]>999) {buf[10]-=1000; buf[11]++;}            \
   1.701 +      (buf)[11]+=DECCOMBMSD[sourhi>>26];}
   1.702 +    #endif
   1.703 +
   1.704 +
   1.705 +    /* Set a decFloat to the maximum positive finite number (Nmax)    */
   1.706 +    #if DECPMAX==7
   1.707 +    #define DFSETNMAX(df)            \
   1.708 +      {DFWORD(df, 0)=0x77f3fcff;}
   1.709 +    #elif DECPMAX==16
   1.710 +    #define DFSETNMAX(df)            \
   1.711 +      {DFWORD(df, 0)=0x77fcff3f;     \
   1.712 +       DFWORD(df, 1)=0xcff3fcff;}
   1.713 +    #elif DECPMAX==34
   1.714 +    #define DFSETNMAX(df)            \
   1.715 +      {DFWORD(df, 0)=0x77ffcff3;     \
   1.716 +       DFWORD(df, 1)=0xfcff3fcf;     \
   1.717 +       DFWORD(df, 2)=0xf3fcff3f;     \
   1.718 +       DFWORD(df, 3)=0xcff3fcff;}
   1.719 +    #endif
   1.720 +
   1.721 +  /* [end of format-dependent macros and constants]                   */
   1.722 +  #endif
   1.723 +
   1.724 +#else
   1.725 +  #error decNumberLocal included more than once
   1.726 +#endif

mercurial