1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40#ifndef DECNUMBERLOCAL_H
41#define DECNUMBERLOCAL_H
42
43 #define DECVERSION "decNumber 3.53"
44 #define DECNLAUTHOR "Mike Cowlishaw"
45
46 #include "libdecnumber/dconfig.h"
47 #include "libdecnumber/decContext.h"
48
49
50
51 #if WORDS_BIGENDIAN
52 #define DECLITEND 0
53 #else
54 #define DECLITEND 1
55 #endif
56
57
58 #define DECUSE64 1
59
60
61 #define DECCHECK 0
62 #define DECALLOC 0
63 #define DECTRACE 0
64
65
66 #define DECBUFFER 36
67
68
69
70
71
72
73
74
75
76
77 #define Flag uint8_t
78 #define Byte int8_t
79 #define uByte uint8_t
80 #define Short int16_t
81 #define uShort uint16_t
82 #define Int int32_t
83 #define uInt uint32_t
84 #define Unit decNumberUnit
85 #if DECUSE64
86 #define Long int64_t
87 #define uLong uint64_t
88 #endif
89
90
91 typedef long int LI;
92 #define DECNOINT 0
93 #if DECNOINT
94
95 #define int ?
96 #define long ??
97 #endif
98
99
100 extern const uByte DECSTICKYTAB[10];
101 extern const uLong DECPOWERS[20];
102
103 extern const uShort DPD2BIN[1024];
104 extern const uShort BIN2DPD[1000];
105 extern const uInt DPD2BINK[1024];
106 extern const uInt DPD2BINM[1024];
107 extern const uByte DPD2BCD8[4096];
108 extern const uByte BIN2BCD8[4000];
109 extern const uShort BCD2DPD[2458];
110
111
112
113
114
115
116 #define LONGMUL32HI(w, u, v) { \
117 uInt u0, u1, v0, v1, w0, w1, w2, t; \
118 u0=u & 0xffff; u1=u>>16; \
119 v0=v & 0xffff; v1=v>>16; \
120 w0=u0*v0; \
121 t=u1*v0 + (w0>>16); \
122 w1=t & 0xffff; w2=t>>16; \
123 w1=u0*v1 + w1; \
124 (w)=u1*v1 + w2 + (w1>>16);}
125
126
127 #define ROUNDUP(i, n) ((((i)+(n)-1)/n)*n)
128
129
130 #define ROUNDDOWN(i, n) (((i)/n)*n)
131 #define ROUNDDOWN4(i) ((i)&~3)
132
133
134
135
136 #define UINTAT(b) (*((uInt *)(b)))
137 #define USHORTAT(b) (*((uShort *)(b)))
138 #define UBYTEAT(b) (*((uByte *)(b)))
139
140
141
142 #define X10(i) (((i)<<1)+((i)<<3))
143 #define X100(i) (((i)<<2)+((i)<<5)+((i)<<6))
144
145
146 #define MAXI(x,y) ((x)<(y)?(y):(x))
147 #define MINI(x,y) ((x)>(y)?(y):(x))
148
149
150 #define BILLION 1000000000
151
152 #define CHARMASK ((((((((uInt)'0')<<8)+'0')<<8)+'0')<<8)+'0')
153
154
155
156
157
158
159
160
161 #define DECNUMMAXP 999999999
162 #define DECNUMMAXE 999999999
163 #define DECNUMMINE -999999999
164 #if (DECNUMMAXP != DEC_MAX_DIGITS)
165 #error Maximum digits mismatch
166 #endif
167 #if (DECNUMMAXE != DEC_MAX_EMAX)
168 #error Maximum exponent mismatch
169 #endif
170 #if (DECNUMMINE != DEC_MIN_EMIN)
171 #error Minimum exponent mismatch
172 #endif
173
174
175
176 #if DECDPUN==1
177 #define DECDPUNMAX 9
178 #define D2UTABLE {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17, \
179 18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, \
180 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47, \
181 48,49}
182 #elif DECDPUN==2
183 #define DECDPUNMAX 99
184 #define D2UTABLE {0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10, \
185 11,11,12,12,13,13,14,14,15,15,16,16,17,17,18, \
186 18,19,19,20,20,21,21,22,22,23,23,24,24,25}
187 #elif DECDPUN==3
188 #define DECDPUNMAX 999
189 #define D2UTABLE {0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7, \
190 8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13, \
191 13,14,14,14,15,15,15,16,16,16,17}
192 #elif DECDPUN==4
193 #define DECDPUNMAX 9999
194 #define D2UTABLE {0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6, \
195 6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11, \
196 11,11,11,12,12,12,12,13}
197 #elif DECDPUN==5
198 #define DECDPUNMAX 99999
199 #define D2UTABLE {0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5, \
200 5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9, \
201 9,9,10,10,10,10}
202 #elif DECDPUN==6
203 #define DECDPUNMAX 999999
204 #define D2UTABLE {0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4, \
205 4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8, \
206 8,8,8,8,8,9}
207 #elif DECDPUN==7
208 #define DECDPUNMAX 9999999
209 #define D2UTABLE {0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3, \
210 4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7, \
211 7,7,7,7,7,7}
212 #elif DECDPUN==8
213 #define DECDPUNMAX 99999999
214 #define D2UTABLE {0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3, \
215 3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6, \
216 6,6,6,6,6,7}
217 #elif DECDPUN==9
218 #define DECDPUNMAX 999999999
219 #define D2UTABLE {0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3, \
220 3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5, \
221 5,5,6,6,6,6}
222 #elif defined(DECDPUN)
223 #error DECDPUN must be in the range 1-9
224 #endif
225
226
227
228 #define DECMAXD2U 49
229 extern const uByte d2utable[DECMAXD2U+1];
230
231
232
233
234 #define ISZERO(dn) decNumberIsZero(dn)
235
236
237
238 #if DECDPUN==8
239 #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+7)>>3))
240 #elif DECDPUN==4
241 #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+3)>>2))
242 #else
243 #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
244 #endif
245
246 #define SD2U(d) (((d)+DECDPUN-1)/DECDPUN)
247
248
249
250 #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
251
252
253
254
255
256
257 #define D2N(d) \
258 ((((SD2U(d)-1)*sizeof(Unit))+sizeof(decNumber)*2-1)/sizeof(decNumber))
259
260
261
262
263
264
265
266
267 #define TODIGIT(u, cut, c, pow) { \
268 *(c)='0'; \
269 pow=DECPOWERS[cut]*2; \
270 if ((u)>pow) { \
271 pow*=4; \
272 if ((u)>=pow) {(u)-=pow; *(c)+=8;} \
273 pow/=2; \
274 if ((u)>=pow) {(u)-=pow; *(c)+=4;} \
275 pow/=2; \
276 } \
277 if ((u)>=pow) {(u)-=pow; *(c)+=2;} \
278 pow/=2; \
279 if ((u)>=pow) {(u)-=pow; *(c)+=1;} \
280 }
281
282
283
284
285
286
287
288
289 typedef struct {
290 uByte *msd;
291 uByte *lsd;
292 uInt sign;
293 Int exponent;
294
295 } bcdnum;
296
297
298 #define EXPISSPECIAL(exp) ((exp)>=DECFLOAT_MinSp)
299 #define EXPISINF(exp) (exp==DECFLOAT_Inf)
300 #define EXPISNAN(exp) (exp==DECFLOAT_qNaN || exp==DECFLOAT_sNaN)
301 #define NUMISSPECIAL(num) (EXPISSPECIAL((num)->exponent))
302
303
304
305
306
307 #define DECWORDS (DECBYTES/4)
308 #define DECWWORDS (DECWBYTES/4)
309 #if DECLITEND
310 #define DFWORD(df, off) ((df)->words[DECWORDS-1-(off)])
311 #define DFBYTE(df, off) ((df)->bytes[DECBYTES-1-(off)])
312 #define DFWWORD(dfw, off) ((dfw)->words[DECWWORDS-1-(off)])
313 #else
314 #define DFWORD(df, off) ((df)->words[off])
315 #define DFBYTE(df, off) ((df)->bytes[off])
316 #define DFWWORD(dfw, off) ((dfw)->words[off])
317 #endif
318
319
320 #define DFISSIGNED(df) (DFWORD(df, 0)&0x80000000)
321 #define DFISSPECIAL(df) ((DFWORD(df, 0)&0x78000000)==0x78000000)
322 #define DFISINF(df) ((DFWORD(df, 0)&0x7c000000)==0x78000000)
323 #define DFISNAN(df) ((DFWORD(df, 0)&0x7c000000)==0x7c000000)
324 #define DFISQNAN(df) ((DFWORD(df, 0)&0x7e000000)==0x7c000000)
325 #define DFISSNAN(df) ((DFWORD(df, 0)&0x7e000000)==0x7e000000)
326
327
328 extern const uInt DECCOMBMSD[64];
329 extern const uInt DECCOMBFROM[48];
330
331
332 #if DECCHECK || DECTRACE
333 extern void decShowNum(const bcdnum *, const char *);
334 #endif
335
336
337 #if defined(DECPMAX)
338
339
340 #define DECPMAX9 (ROUNDUP(DECPMAX, 9)/9)
341
342 #define SINGLEZERO 0x22500000
343 #define DOUBLEZERO 0x22380000
344 #define QUADZERO 0x22080000
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361 #if DECPMAX==7
362 #define ZEROWORD SINGLEZERO
363
364 #define DFISZERO(df) ((DFWORD(df, 0)&0x1c0fffff)==0 \
365 && (DFWORD(df, 0)&0x60000000)!=0x60000000)
366 #elif DECPMAX==16
367 #define ZEROWORD DOUBLEZERO
368 #define DFISZERO(df) ((DFWORD(df, 1)==0 \
369 && (DFWORD(df, 0)&0x1c03ffff)==0 \
370 && (DFWORD(df, 0)&0x60000000)!=0x60000000))
371 #define DFISINT(df) ((DFWORD(df, 0)&0x63fc0000)==0x22380000 \
372 ||(DFWORD(df, 0)&0x7bfc0000)==0x6a380000)
373 #define DFISUINT01(df) ((DFWORD(df, 0)&0xfbfc0000)==0x22380000)
374 #define DFISCCZERO(df) (DFWORD(df, 1)==0 \
375 && (DFWORD(df, 0)&0x0003ffff)==0)
376 #define DFISCC01(df) ((DFWORD(df, 0)&~0xfffc9124)==0 \
377 && (DFWORD(df, 1)&~0x49124491)==0)
378 #elif DECPMAX==34
379 #define ZEROWORD QUADZERO
380 #define DFISZERO(df) ((DFWORD(df, 3)==0 \
381 && DFWORD(df, 2)==0 \
382 && DFWORD(df, 1)==0 \
383 && (DFWORD(df, 0)&0x1c003fff)==0 \
384 && (DFWORD(df, 0)&0x60000000)!=0x60000000))
385 #define DFISINT(df) ((DFWORD(df, 0)&0x63ffc000)==0x22080000 \
386 ||(DFWORD(df, 0)&0x7bffc000)==0x6a080000)
387 #define DFISUINT01(df) ((DFWORD(df, 0)&0xfbffc000)==0x22080000)
388 #define DFISCCZERO(df) (DFWORD(df, 3)==0 \
389 && DFWORD(df, 2)==0 \
390 && DFWORD(df, 1)==0 \
391 && (DFWORD(df, 0)&0x00003fff)==0)
392
393 #define DFISCC01(df) ((DFWORD(df, 0)&~0xffffc912)==0 \
394 && (DFWORD(df, 1)&~0x44912449)==0 \
395 && (DFWORD(df, 2)&~0x12449124)==0 \
396 && (DFWORD(df, 3)&~0x49124491)==0)
397 #endif
398
399
400
401
402 #define CANONDPD(dpd) (((dpd)&0x300)==0 || ((dpd)&0x6e)!=0x6e)
403
404 #define CANONDPDOFF(dpd, k) (((dpd)&(0x300<<(k)))==0 \
405 || ((dpd)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k)))
406
407
408 #define CANONDPDTWO(hi, lo, k) (((hi)&(0x300>>(32-(k))))==0 \
409 || ((hi)&(0x6e>>(32-(k))))!=(0x6e>>(32-(k))) \
410 || ((lo)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k)))
411
412
413
414
415 #if DECPMAX==7
416 #define ISCOEFFZERO(u) (UINTAT((u)+DECPMAX-4)==0 \
417 && UINTAT((u)+DECPMAX-7)==0)
418 #elif DECPMAX==16
419 #define ISCOEFFZERO(u) (UINTAT((u)+DECPMAX-4)==0 \
420 && (UINTAT((u)+DECPMAX-8)+UINTAT((u)+DECPMAX-12) \
421 +UINTAT((u)+DECPMAX-16))==0)
422 #elif DECPMAX==34
423 #define ISCOEFFZERO(u) (UINTAT((u)+DECPMAX-4)==0 \
424 && (UINTAT((u)+DECPMAX-8) +UINTAT((u)+DECPMAX-12) \
425 +UINTAT((u)+DECPMAX-16)+UINTAT((u)+DECPMAX-20) \
426 +UINTAT((u)+DECPMAX-24)+UINTAT((u)+DECPMAX-28) \
427 +UINTAT((u)+DECPMAX-32)+USHORTAT((u)+DECPMAX-34))==0)
428 #endif
429
430
431
432 #define GETECON(df) ((Int)((DFWORD((df), 0)&0x03ffffff)>>(32-6-DECECONL)))
433
434 #define GETWECON(df) ((Int)((DFWWORD((df), 0)&0x03ffffff)>>(32-6-DECWECONL)))
435
436 #define GETEXP(df) ((Int)(DECCOMBEXP[DFWORD((df), 0)>>26]+GETECON(df)))
437
438 #define GETEXPUN(df) ((Int)GETEXP(df)-DECBIAS)
439
440 #define GETMSD(df) (DECCOMBMSD[DFWORD((df), 0)>>26])
441
442
443
444 #define ECONMASK ((0x03ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))
445
446 #define ECONNANMASK ((0x01ffffff>>(32-6-DECECONL))<<(32-6-DECECONL))
447
448
449
450
451
452
453
454
455
456 #define dpd2bcd8(u, dpd) { \
457 UINTAT(u)=UINTAT(&DPD2BCD8[((dpd)&0x3ff)*4]);}
458
459 #define dpd2bcd83(u, dpd) { \
460 *(u)=DPD2BCD8[((dpd)&0x3ff)*4]; \
461 *(u+1)=DPD2BCD8[((dpd)&0x3ff)*4+1]; \
462 *(u+2)=DPD2BCD8[((dpd)&0x3ff)*4+2];}
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478 #if DECPMAX==7
479 #define GETCOEFF(df, bcd) { \
480 uInt sourhi=DFWORD(df, 0); \
481 *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
482 dpd2bcd8(bcd+1, sourhi>>10); \
483 dpd2bcd83(bcd+4, sourhi);}
484 #define GETWCOEFF(df, bcd) { \
485 uInt sourhi=DFWWORD(df, 0); \
486 uInt sourlo=DFWWORD(df, 1); \
487 *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
488 dpd2bcd8(bcd+1, sourhi>>8); \
489 dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30)); \
490 dpd2bcd8(bcd+7, sourlo>>20); \
491 dpd2bcd8(bcd+10, sourlo>>10); \
492 dpd2bcd83(bcd+13, sourlo);}
493
494 #elif DECPMAX==16
495 #define GETCOEFF(df, bcd) { \
496 uInt sourhi=DFWORD(df, 0); \
497 uInt sourlo=DFWORD(df, 1); \
498 *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
499 dpd2bcd8(bcd+1, sourhi>>8); \
500 dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30)); \
501 dpd2bcd8(bcd+7, sourlo>>20); \
502 dpd2bcd8(bcd+10, sourlo>>10); \
503 dpd2bcd83(bcd+13, sourlo);}
504 #define GETWCOEFF(df, bcd) { \
505 uInt sourhi=DFWWORD(df, 0); \
506 uInt sourmh=DFWWORD(df, 1); \
507 uInt sourml=DFWWORD(df, 2); \
508 uInt sourlo=DFWWORD(df, 3); \
509 *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
510 dpd2bcd8(bcd+1, sourhi>>4); \
511 dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26)); \
512 dpd2bcd8(bcd+7, sourmh>>16); \
513 dpd2bcd8(bcd+10, sourmh>>6); \
514 dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28)); \
515 dpd2bcd8(bcd+16, sourml>>18); \
516 dpd2bcd8(bcd+19, sourml>>8); \
517 dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30)); \
518 dpd2bcd8(bcd+25, sourlo>>20); \
519 dpd2bcd8(bcd+28, sourlo>>10); \
520 dpd2bcd83(bcd+31, sourlo);}
521
522 #elif DECPMAX==34
523 #define GETCOEFF(df, bcd) { \
524 uInt sourhi=DFWORD(df, 0); \
525 uInt sourmh=DFWORD(df, 1); \
526 uInt sourml=DFWORD(df, 2); \
527 uInt sourlo=DFWORD(df, 3); \
528 *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \
529 dpd2bcd8(bcd+1, sourhi>>4); \
530 dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26)); \
531 dpd2bcd8(bcd+7, sourmh>>16); \
532 dpd2bcd8(bcd+10, sourmh>>6); \
533 dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28)); \
534 dpd2bcd8(bcd+16, sourml>>18); \
535 dpd2bcd8(bcd+19, sourml>>8); \
536 dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30)); \
537 dpd2bcd8(bcd+25, sourlo>>20); \
538 dpd2bcd8(bcd+28, sourlo>>10); \
539 dpd2bcd83(bcd+31, sourlo);}
540
541 #define GETWCOEFF(df, bcd) {??}
542 #endif
543
544
545
546
547
548
549
550
551
552
553
554 #define DPD2BIN0 DPD2BIN
555
556 #if DECPMAX==7
557 #define GETCOEFFBILL(df, buf) { \
558 uInt sourhi=DFWORD(df, 0); \
559 (buf)[0]=DPD2BIN0[sourhi&0x3ff] \
560 +DPD2BINK[(sourhi>>10)&0x3ff] \
561 +DPD2BINM[DECCOMBMSD[sourhi>>26]];}
562
563 #elif DECPMAX==16
564 #define GETCOEFFBILL(df, buf) { \
565 uInt sourhi, sourlo; \
566 sourlo=DFWORD(df, 1); \
567 (buf)[0]=DPD2BIN0[sourlo&0x3ff] \
568 +DPD2BINK[(sourlo>>10)&0x3ff] \
569 +DPD2BINM[(sourlo>>20)&0x3ff]; \
570 sourhi=DFWORD(df, 0); \
571 (buf)[1]=DPD2BIN0[((sourhi<<2) | (sourlo>>30))&0x3ff] \
572 +DPD2BINK[(sourhi>>8)&0x3ff] \
573 +DPD2BINM[DECCOMBMSD[sourhi>>26]];}
574
575 #elif DECPMAX==34
576 #define GETCOEFFBILL(df, buf) { \
577 uInt sourhi, sourmh, sourml, sourlo; \
578 sourlo=DFWORD(df, 3); \
579 (buf)[0]=DPD2BIN0[sourlo&0x3ff] \
580 +DPD2BINK[(sourlo>>10)&0x3ff] \
581 +DPD2BINM[(sourlo>>20)&0x3ff]; \
582 sourml=DFWORD(df, 2); \
583 (buf)[1]=DPD2BIN0[((sourml<<2) | (sourlo>>30))&0x3ff] \
584 +DPD2BINK[(sourml>>8)&0x3ff] \
585 +DPD2BINM[(sourml>>18)&0x3ff]; \
586 sourmh=DFWORD(df, 1); \
587 (buf)[2]=DPD2BIN0[((sourmh<<4) | (sourml>>28))&0x3ff] \
588 +DPD2BINK[(sourmh>>6)&0x3ff] \
589 +DPD2BINM[(sourmh>>16)&0x3ff]; \
590 sourhi=DFWORD(df, 0); \
591 (buf)[3]=DPD2BIN0[((sourhi<<6) | (sourmh>>26))&0x3ff] \
592 +DPD2BINK[(sourhi>>4)&0x3ff] \
593 +DPD2BINM[DECCOMBMSD[sourhi>>26]];}
594
595 #endif
596
597
598
599
600
601
602
603 #if DECPMAX==7
604 #define GETCOEFFTHOU(df, buf) { \
605 uInt sourhi=DFWORD(df, 0); \
606 (buf)[0]=DPD2BIN[sourhi&0x3ff]; \
607 (buf)[1]=DPD2BIN[(sourhi>>10)&0x3ff]; \
608 (buf)[2]=DECCOMBMSD[sourhi>>26];}
609
610 #elif DECPMAX==16
611 #define GETCOEFFTHOU(df, buf) { \
612 uInt sourhi, sourlo; \
613 sourlo=DFWORD(df, 1); \
614 (buf)[0]=DPD2BIN[sourlo&0x3ff]; \
615 (buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff]; \
616 (buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff]; \
617 sourhi=DFWORD(df, 0); \
618 (buf)[3]=DPD2BIN[((sourhi<<2) | (sourlo>>30))&0x3ff]; \
619 (buf)[4]=DPD2BIN[(sourhi>>8)&0x3ff]; \
620 (buf)[5]=DECCOMBMSD[sourhi>>26];}
621
622 #elif DECPMAX==34
623 #define GETCOEFFTHOU(df, buf) { \
624 uInt sourhi, sourmh, sourml, sourlo; \
625 sourlo=DFWORD(df, 3); \
626 (buf)[0]=DPD2BIN[sourlo&0x3ff]; \
627 (buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff]; \
628 (buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff]; \
629 sourml=DFWORD(df, 2); \
630 (buf)[3]=DPD2BIN[((sourml<<2) | (sourlo>>30))&0x3ff]; \
631 (buf)[4]=DPD2BIN[(sourml>>8)&0x3ff]; \
632 (buf)[5]=DPD2BIN[(sourml>>18)&0x3ff]; \
633 sourmh=DFWORD(df, 1); \
634 (buf)[6]=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff]; \
635 (buf)[7]=DPD2BIN[(sourmh>>6)&0x3ff]; \
636 (buf)[8]=DPD2BIN[(sourmh>>16)&0x3ff]; \
637 sourhi=DFWORD(df, 0); \
638 (buf)[9]=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff]; \
639 (buf)[10]=DPD2BIN[(sourhi>>4)&0x3ff]; \
640 (buf)[11]=DECCOMBMSD[sourhi>>26];}
641
642 #endif
643
644
645 #if DECPMAX==7
646 #define DFSETNMAX(df) \
647 {DFWORD(df, 0)=0x77f3fcff;}
648 #elif DECPMAX==16
649 #define DFSETNMAX(df) \
650 {DFWORD(df, 0)=0x77fcff3f; \
651 DFWORD(df, 1)=0xcff3fcff;}
652 #elif DECPMAX==34
653 #define DFSETNMAX(df) \
654 {DFWORD(df, 0)=0x77ffcff3; \
655 DFWORD(df, 1)=0xfcff3fcf; \
656 DFWORD(df, 2)=0xf3fcff3f; \
657 DFWORD(df, 3)=0xcff3fcff;}
658 #endif
659
660
661 #endif
662
663#endif
664