1 /****************************************************************
3 * The author of this software is David M. Gay.
5 * Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose without fee is hereby granted, provided that this entire notice
9 * is included in all copies of any software which is or includes a copy
10 * or modification of this software and in all copies of the supporting
11 * documentation for such software.
13 * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
14 * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
15 * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
16 * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
18 ***************************************************************/
20 /* Please send bug reports to David M. Gay (dmg at acm dot org,
21 * with " at " changed at "@" and " dot " changed to "."). */
23 /* On a machine with IEEE extended-precision registers, it is
24 * necessary to specify double-precision (53-bit) rounding precision
25 * before invoking strtod or dtoa. If the machine uses (the equivalent
26 * of) Intel 80x87 arithmetic, the call
27 * _control87(PC_53, MCW_PC);
28 * does this with many compilers. Whether this or another call is
29 * appropriate depends on the compiler; for this to work, it may be
30 * necessary to #include "float.h" or another system-dependent header
31 * file. When needed, this call avoids double rounding, which can
32 * cause one bit errors, e.g., with strtod on 8.3e26 or 6.3876e-16.
35 /* strtod for IEEE-, VAX-, and IBM-arithmetic machines.
36 * (Note that IEEE arithmetic is disabled by gcc's -ffast-math flag.)
38 * This strtod returns a nearest machine number to the input decimal
39 * string (or sets errno to ERANGE). With IEEE arithmetic, ties are
40 * broken by the IEEE round-even rule. Otherwise ties are broken by
41 * biased rounding (add half and chop).
43 * Inspired loosely by William D. Clinger's paper "How to Read Floating
44 * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
48 * 1. We only require IEEE, IBM, or VAX double-precision
49 * arithmetic (not IEEE double-extended).
50 * 2. We get by with floating-point arithmetic in a case that
51 * Clinger missed -- when we're computing d * 10^n
52 * for a small integer d and the integer n is not too
53 * much larger than 22 (the maximum integer k for which
54 * we can represent 10^k exactly), we may be able to
55 * compute (d*10^k) * 10^(e-k) with just one roundoff.
56 * 3. Rather than a bit-at-a-time adjustment of the binary
57 * result in the hard case, we use floating-point
58 * arithmetic to determine the adjustment to within
59 * one bit; only in really hard cases do we need to
60 * compute a second residual.
61 * 4. Because of 3., we don't need a large table of powers of 10
62 * for ten-to-e (just some small tables, e.g. of 10^k
67 * #define IEEE_8087 for IEEE-arithmetic machines where the least
68 * significant byte has the lowest address.
69 * #define IEEE_MC68k for IEEE-arithmetic machines where the most
70 * significant byte has the lowest address.
71 * #define Long int on machines with 32-bit ints and 64-bit longs.
72 * #define IBM for IBM mainframe-style floating-point arithmetic.
73 * #define VAX for VAX-style floating-point arithmetic (D_floating).
74 * #define No_leftright to omit left-right logic in fast floating-point
75 * computation of dtoa. This will cause dtoa modes 4 and 5 to be
76 * treated the same as modes 2 and 3 for some inputs.
77 * #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
78 * and strtod and dtoa should round accordingly. Unless Trust_FLT_ROUNDS
79 * is also #defined, fegetround() will be queried for the rounding mode.
80 * Note that both FLT_ROUNDS and fegetround() are specified by the C99
81 * standard (and are specified to be consistent, with fesetround()
82 * affecting the value of FLT_ROUNDS), but that some (Linux) systems
83 * do not work correctly in this regard, so using fegetround() is more
84 * portable than using FLT_ROUNDS directly.
85 * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3
86 * and Honor_FLT_ROUNDS is not #defined.
87 * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
88 * that use extended-precision instructions to compute rounded
89 * products and quotients) with IBM.
90 * #define ROUND_BIASED for IEEE-format with biased rounding and arithmetic
91 * that rounds toward +Infinity.
92 * #define ROUND_BIASED_without_Round_Up for IEEE-format with biased
93 * rounding when the underlying floating-point arithmetic uses
94 * unbiased rounding. This prevent using ordinary floating-point
95 * arithmetic when the result could be computed with one rounding error.
96 * #define Inaccurate_Divide for IEEE-format with correctly rounded
97 * products but inaccurate quotients, e.g., for Intel i860.
98 * #define NO_LONG_LONG on machines that do not have a "long long"
99 * integer type (of >= 64 bits). On such machines, you can
100 * #define Just_16 to store 16 bits per 32-bit Long when doing
101 * high-precision integer arithmetic. Whether this speeds things
102 * up or slows things down depends on the machine and the number
103 * being converted. If long long is available and the name is
104 * something other than "long long", #define Llong to be the name,
105 * and if "unsigned Llong" does not work as an unsigned version of
106 * Llong, #define #ULLong to be the corresponding unsigned type.
107 * #define Bad_float_h if your system lacks a float.h or if it does not
108 * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP,
109 * FLT_RADIX, FLT_ROUNDS, and DBL_MAX.
110 * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n)
111 * if memory is available and otherwise does something you deem
112 * appropriate. If MALLOC is undefined, malloc will be invoked
113 * directly -- and assumed always to succeed. Similarly, if you
114 * want something other than the system's free() to be called to
115 * recycle memory acquired from MALLOC, #define FREE to be the
116 * name of the alternate routine. (FREE or free is only called in
117 * pathological cases, e.g., in a dtoa call after a dtoa return in
118 * mode 3 with thousands of digits requested.)
119 * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making
120 * memory allocations from a private pool of memory when possible.
121 * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes,
122 * unless #defined to be a different length. This default length
123 * suffices to get rid of MALLOC calls except for unusual cases,
124 * such as decimal-to-binary conversion of a very long string of
125 * digits. The longest string dtoa can return is about 751 bytes
126 * long. For conversions by strtod of strings of 800 digits and
127 * all dtoa conversions in single-threaded executions with 8-byte
128 * pointers, PRIVATE_MEM >= 7400 appears to suffice; with 4-byte
129 * pointers, PRIVATE_MEM >= 7112 appears adequate.
130 * #define NO_INFNAN_CHECK if you do not wish to have INFNAN_CHECK
131 * #defined automatically on IEEE systems. On such systems,
132 * when INFNAN_CHECK is #defined, strtod checks
133 * for Infinity and NaN (case insensitively). On some systems
134 * (e.g., some HP systems), it may be necessary to #define NAN_WORD0
135 * appropriately -- to the most significant word of a quiet NaN.
136 * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)
137 * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined,
138 * strtod also accepts (case insensitively) strings of the form
139 * NaN(x), where x is a string of hexadecimal digits and spaces;
140 * if there is only one string of hexadecimal digits, it is taken
141 * for the 52 fraction bits of the resulting NaN; if there are two
142 * or more strings of hex digits, the first is for the high 20 bits,
143 * the second and subsequent for the low 32 bits, with intervening
144 * white space ignored; but if this results in none of the 52
145 * fraction bits being on (an IEEE Infinity symbol), then NAN_WORD0
146 * and NAN_WORD1 are used instead.
147 * #define MULTIPLE_THREADS if the system offers preemptively scheduled
148 * multiple threads. In this case, you must provide (or suitably
149 * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed
150 * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed
151 * in pow5mult, ensures lazy evaluation of only one copy of high
152 * powers of 5; omitting this lock would introduce a small
153 * probability of wasting memory, but would otherwise be harmless.)
154 * You must also invoke freedtoa(s) to free the value s returned by
155 * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined.
157 * When MULTIPLE_THREADS is #defined, this source file provides
158 * void set_max_dtoa_threads(unsigned int n);
160 * unsigned int dtoa_get_threadno(void);
161 * to be available (possibly provided by
162 * #define dtoa_get_threadno omp_get_thread_num
163 * if OpenMP is in use or by
164 * #define dtoa_get_threadno pthread_self
165 * if Pthreads is in use), to return the current thread number.
166 * If set_max_dtoa_threads(n) was called and the current thread
167 * number is k with k < n, then calls on ACQUIRE_DTOA_LOCK(...) and
168 * FREE_DTOA_LOCK(...) are avoided; instead each thread with thread
169 * number < n has a separate copy of relevant data structures.
170 * After set_max_dtoa_threads(n), a call set_max_dtoa_threads(m)
171 * with m <= n has has no effect, but a call with m > n is honored.
172 * Such a call invokes REALLOC (assumed to be "realloc" if REALLOC
173 * is not #defined) to extend the size of the relevant array.
175 * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that
176 * avoids underflows on inputs whose result does not underflow.
177 * If you #define NO_IEEE_Scale on a machine that uses IEEE-format
178 * floating-point numbers and flushes underflows to zero rather
179 * than implementing gradual underflow, then you must also #define
181 * #define USE_LOCALE to use the current locale's decimal_point value.
182 * #define SET_INEXACT if IEEE arithmetic is being used and extra
183 * computation should be done to set the inexact flag when the
184 * result is inexact and avoid setting inexact when the result
185 * is exact. In this case, dtoa.c must be compiled in
186 * an environment, perhaps provided by #include "dtoa.c" in a
187 * suitable wrapper, that defines two functions,
188 * int get_inexact(void);
189 * void clear_inexact(void);
190 * such that get_inexact() returns a nonzero value if the
191 * inexact bit is already set, and clear_inexact() sets the
192 * inexact bit to 0. When SET_INEXACT is #defined, strtod
193 * also does extra computations to set the underflow and overflow
194 * flags when appropriate (i.e., when the result is tiny and
195 * inexact or when it is a numeric value rounded to +-infinity).
196 * #define NO_ERRNO if strtod should not assign errno = ERANGE when
197 * the result overflows to +-Infinity or underflows to 0.
198 * When errno should be assigned, under seemingly rare conditions
199 * it may be necessary to define Set_errno(x) suitably, e.g., in
200 * a local errno.h, such as
202 * #define Set_errno(x) _set_errno(x)
203 * #define NO_HEX_FP to omit recognition of hexadecimal floating-point
205 * #define NO_STRTOD_BIGCOMP (on IEEE-arithmetic systems only for now)
206 * to disable logic for "fast" testing of very long input strings
207 * to strtod. This testing proceeds by initially truncating the
208 * input string, then if necessary comparing the whole string with
209 * a decimal expansion to decide close cases. This logic is only
210 * used for input more than STRTOD_DIGLIM digits long (default 40).
213 /* Begin Wireshark defines and includes */
214 #include <wireshark.h>
217 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
219 #elif G_BYTE_ORDER == G_BIG_ENDIAN
222 #error "Unsupported byte order"
225 #define MALLOC g_malloc
226 #define REALLOC g_realloc
229 typedef int32_t Long
;
230 typedef uint32_t ULong
;
231 typedef uint64_t ULLong
;
236 /* disable: "warning C4146: unary minus operator applied to unsigned type, result still unsigned" */
237 #pragma warning(disable:4146)
240 /* End Wireshark defines and includes */
246 typedef unsigned Long ULong
;
252 #define Bug(x) {ws_error("%s", x);}
254 int dtoa_stats
[7]; /* strtod_{64,96,bigcomp},dtoa_{exact,64,96,bigcomp} */
256 #define assert(x) /*nothing*/
257 #define Debug(x) /*nothing*/
267 #ifdef Honor_FLT_ROUNDS
268 #ifndef Trust_FLT_ROUNDS
273 #ifndef Omit_Private_Memory
275 #define PRIVATE_MEM 2304
277 #define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
278 static double private_mem
[PRIVATE_mem
], *pmem_next
= private_mem
;
282 #undef Avoid_Underflow
291 #ifndef NO_INFNAN_CHECK
297 #define NO_STRTOD_BIGCOMP
302 #ifdef NO_ERRNO /*{*/
307 #define Set_errno(x) errno = x
315 #define DBL_MAX_10_EXP 308
316 #define DBL_MAX_EXP 1024
318 #endif /*IEEE_Arith*/
322 #define DBL_MAX_10_EXP 75
323 #define DBL_MAX_EXP 63
325 #define DBL_MAX 7.2370055773322621e+75
330 #define DBL_MAX_10_EXP 38
331 #define DBL_MAX_EXP 127
333 #define DBL_MAX 1.7014118346046923e+38
337 #define LONG_MAX 2147483647
340 #else /* ifndef Bad_float_h */
342 #endif /* Bad_float_h */
352 #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
353 Exactly one of IEEE_8087
, IEEE_MC68k
, VAX
, or IBM should be defined
.
358 #ifdef NO_LONG_LONG /*{{*/
362 /* When Pack_32 is not defined, we store 16 bits per 32-bit Long.
363 * This makes some inner loops simpler and sometimes saves work
364 * during multiplications, but it often seems to make things slightly
365 * slower. Hence the default is now to store 32 bits per Long.
368 #else /*}{ long long available */
370 #define Llong long long
373 #define ULLong unsigned Llong
375 #ifndef NO_BF96 /*{*/
379 #define dtoa_divmax 27
381 int dtoa_divmax
= 2; /* Permit experimenting: on some systems, 64-bit integer */
382 /* division is slow enough that we may sometimes want to */
383 /* avoid using it. We assume (but do not check) that */
384 /* dtoa_divmax <= 27.*/
387 typedef struct BF96
{ /* Normalized 96-bit software floating point numbers */
388 unsigned int b0
,b1
,b2
; /* b0 = most significant, binary point just to its left */
389 int e
; /* number represented = b * 2^e, with .5 <= b < 1 */
392 static BF96 pten
[667] = {
393 { 0xeef453d6, 0x923bd65a, 0x113faa29, -1136 },
394 { 0x9558b466, 0x1b6565f8, 0x4ac7ca59, -1132 },
395 { 0xbaaee17f, 0xa23ebf76, 0x5d79bcf0, -1129 },
396 { 0xe95a99df, 0x8ace6f53, 0xf4d82c2c, -1126 },
397 { 0x91d8a02b, 0xb6c10594, 0x79071b9b, -1122 },
398 { 0xb64ec836, 0xa47146f9, 0x9748e282, -1119 },
399 { 0xe3e27a44, 0x4d8d98b7, 0xfd1b1b23, -1116 },
400 { 0x8e6d8c6a, 0xb0787f72, 0xfe30f0f5, -1112 },
401 { 0xb208ef85, 0x5c969f4f, 0xbdbd2d33, -1109 },
402 { 0xde8b2b66, 0xb3bc4723, 0xad2c7880, -1106 },
403 { 0x8b16fb20, 0x3055ac76, 0x4c3bcb50, -1102 },
404 { 0xaddcb9e8, 0x3c6b1793, 0xdf4abe24, -1099 },
405 { 0xd953e862, 0x4b85dd78, 0xd71d6dad, -1096 },
406 { 0x87d4713d, 0x6f33aa6b, 0x8672648c, -1092 },
407 { 0xa9c98d8c, 0xcb009506, 0x680efdaf, -1089 },
408 { 0xd43bf0ef, 0xfdc0ba48, 0x0212bd1b, -1086 },
409 { 0x84a57695, 0xfe98746d, 0x014bb630, -1082 },
410 { 0xa5ced43b, 0x7e3e9188, 0x419ea3bd, -1079 },
411 { 0xcf42894a, 0x5dce35ea, 0x52064cac, -1076 },
412 { 0x818995ce, 0x7aa0e1b2, 0x7343efeb, -1072 },
413 { 0xa1ebfb42, 0x19491a1f, 0x1014ebe6, -1069 },
414 { 0xca66fa12, 0x9f9b60a6, 0xd41a26e0, -1066 },
415 { 0xfd00b897, 0x478238d0, 0x8920b098, -1063 },
416 { 0x9e20735e, 0x8cb16382, 0x55b46e5f, -1059 },
417 { 0xc5a89036, 0x2fddbc62, 0xeb2189f7, -1056 },
418 { 0xf712b443, 0xbbd52b7b, 0xa5e9ec75, -1053 },
419 { 0x9a6bb0aa, 0x55653b2d, 0x47b233c9, -1049 },
420 { 0xc1069cd4, 0xeabe89f8, 0x999ec0bb, -1046 },
421 { 0xf148440a, 0x256e2c76, 0xc00670ea, -1043 },
422 { 0x96cd2a86, 0x5764dbca, 0x38040692, -1039 },
423 { 0xbc807527, 0xed3e12bc, 0xc6050837, -1036 },
424 { 0xeba09271, 0xe88d976b, 0xf7864a44, -1033 },
425 { 0x93445b87, 0x31587ea3, 0x7ab3ee6a, -1029 },
426 { 0xb8157268, 0xfdae9e4c, 0x5960ea05, -1026 },
427 { 0xe61acf03, 0x3d1a45df, 0x6fb92487, -1023 },
428 { 0x8fd0c162, 0x06306bab, 0xa5d3b6d4, -1019 },
429 { 0xb3c4f1ba, 0x87bc8696, 0x8f48a489, -1016 },
430 { 0xe0b62e29, 0x29aba83c, 0x331acdab, -1013 },
431 { 0x8c71dcd9, 0xba0b4925, 0x9ff0c08b, -1009 },
432 { 0xaf8e5410, 0x288e1b6f, 0x07ecf0ae, -1006 },
433 { 0xdb71e914, 0x32b1a24a, 0xc9e82cd9, -1003 },
434 { 0x892731ac, 0x9faf056e, 0xbe311c08, -999 },
435 { 0xab70fe17, 0xc79ac6ca, 0x6dbd630a, -996 },
436 { 0xd64d3d9d, 0xb981787d, 0x092cbbcc, -993 },
437 { 0x85f04682, 0x93f0eb4e, 0x25bbf560, -989 },
438 { 0xa76c5823, 0x38ed2621, 0xaf2af2b8, -986 },
439 { 0xd1476e2c, 0x07286faa, 0x1af5af66, -983 },
440 { 0x82cca4db, 0x847945ca, 0x50d98d9f, -979 },
441 { 0xa37fce12, 0x6597973c, 0xe50ff107, -976 },
442 { 0xcc5fc196, 0xfefd7d0c, 0x1e53ed49, -973 },
443 { 0xff77b1fc, 0xbebcdc4f, 0x25e8e89c, -970 },
444 { 0x9faacf3d, 0xf73609b1, 0x77b19161, -966 },
445 { 0xc795830d, 0x75038c1d, 0xd59df5b9, -963 },
446 { 0xf97ae3d0, 0xd2446f25, 0x4b057328, -960 },
447 { 0x9becce62, 0x836ac577, 0x4ee367f9, -956 },
448 { 0xc2e801fb, 0x244576d5, 0x229c41f7, -953 },
449 { 0xf3a20279, 0xed56d48a, 0x6b435275, -950 },
450 { 0x9845418c, 0x345644d6, 0x830a1389, -946 },
451 { 0xbe5691ef, 0x416bd60c, 0x23cc986b, -943 },
452 { 0xedec366b, 0x11c6cb8f, 0x2cbfbe86, -940 },
453 { 0x94b3a202, 0xeb1c3f39, 0x7bf7d714, -936 },
454 { 0xb9e08a83, 0xa5e34f07, 0xdaf5ccd9, -933 },
455 { 0xe858ad24, 0x8f5c22c9, 0xd1b3400f, -930 },
456 { 0x91376c36, 0xd99995be, 0x23100809, -926 },
457 { 0xb5854744, 0x8ffffb2d, 0xabd40a0c, -923 },
458 { 0xe2e69915, 0xb3fff9f9, 0x16c90c8f, -920 },
459 { 0x8dd01fad, 0x907ffc3b, 0xae3da7d9, -916 },
460 { 0xb1442798, 0xf49ffb4a, 0x99cd11cf, -913 },
461 { 0xdd95317f, 0x31c7fa1d, 0x40405643, -910 },
462 { 0x8a7d3eef, 0x7f1cfc52, 0x482835ea, -906 },
463 { 0xad1c8eab, 0x5ee43b66, 0xda324365, -903 },
464 { 0xd863b256, 0x369d4a40, 0x90bed43e, -900 },
465 { 0x873e4f75, 0xe2224e68, 0x5a7744a6, -896 },
466 { 0xa90de353, 0x5aaae202, 0x711515d0, -893 },
467 { 0xd3515c28, 0x31559a83, 0x0d5a5b44, -890 },
468 { 0x8412d999, 0x1ed58091, 0xe858790a, -886 },
469 { 0xa5178fff, 0x668ae0b6, 0x626e974d, -883 },
470 { 0xce5d73ff, 0x402d98e3, 0xfb0a3d21, -880 },
471 { 0x80fa687f, 0x881c7f8e, 0x7ce66634, -876 },
472 { 0xa139029f, 0x6a239f72, 0x1c1fffc1, -873 },
473 { 0xc9874347, 0x44ac874e, 0xa327ffb2, -870 },
474 { 0xfbe91419, 0x15d7a922, 0x4bf1ff9f, -867 },
475 { 0x9d71ac8f, 0xada6c9b5, 0x6f773fc3, -863 },
476 { 0xc4ce17b3, 0x99107c22, 0xcb550fb4, -860 },
477 { 0xf6019da0, 0x7f549b2b, 0x7e2a53a1, -857 },
478 { 0x99c10284, 0x4f94e0fb, 0x2eda7444, -853 },
479 { 0xc0314325, 0x637a1939, 0xfa911155, -850 },
480 { 0xf03d93ee, 0xbc589f88, 0x793555ab, -847 },
481 { 0x96267c75, 0x35b763b5, 0x4bc1558b, -843 },
482 { 0xbbb01b92, 0x83253ca2, 0x9eb1aaed, -840 },
483 { 0xea9c2277, 0x23ee8bcb, 0x465e15a9, -837 },
484 { 0x92a1958a, 0x7675175f, 0x0bfacd89, -833 },
485 { 0xb749faed, 0x14125d36, 0xcef980ec, -830 },
486 { 0xe51c79a8, 0x5916f484, 0x82b7e127, -827 },
487 { 0x8f31cc09, 0x37ae58d2, 0xd1b2ecb8, -823 },
488 { 0xb2fe3f0b, 0x8599ef07, 0x861fa7e6, -820 },
489 { 0xdfbdcece, 0x67006ac9, 0x67a791e0, -817 },
490 { 0x8bd6a141, 0x006042bd, 0xe0c8bb2c, -813 },
491 { 0xaecc4991, 0x4078536d, 0x58fae9f7, -810 },
492 { 0xda7f5bf5, 0x90966848, 0xaf39a475, -807 },
493 { 0x888f9979, 0x7a5e012d, 0x6d8406c9, -803 },
494 { 0xaab37fd7, 0xd8f58178, 0xc8e5087b, -800 },
495 { 0xd5605fcd, 0xcf32e1d6, 0xfb1e4a9a, -797 },
496 { 0x855c3be0, 0xa17fcd26, 0x5cf2eea0, -793 },
497 { 0xa6b34ad8, 0xc9dfc06f, 0xf42faa48, -790 },
498 { 0xd0601d8e, 0xfc57b08b, 0xf13b94da, -787 },
499 { 0x823c1279, 0x5db6ce57, 0x76c53d08, -783 },
500 { 0xa2cb1717, 0xb52481ed, 0x54768c4b, -780 },
501 { 0xcb7ddcdd, 0xa26da268, 0xa9942f5d, -777 },
502 { 0xfe5d5415, 0x0b090b02, 0xd3f93b35, -774 },
503 { 0x9efa548d, 0x26e5a6e1, 0xc47bc501, -770 },
504 { 0xc6b8e9b0, 0x709f109a, 0x359ab641, -767 },
505 { 0xf867241c, 0x8cc6d4c0, 0xc30163d2, -764 },
506 { 0x9b407691, 0xd7fc44f8, 0x79e0de63, -760 },
507 { 0xc2109436, 0x4dfb5636, 0x985915fc, -757 },
508 { 0xf294b943, 0xe17a2bc4, 0x3e6f5b7b, -754 },
509 { 0x979cf3ca, 0x6cec5b5a, 0xa705992c, -750 },
510 { 0xbd8430bd, 0x08277231, 0x50c6ff78, -747 },
511 { 0xece53cec, 0x4a314ebd, 0xa4f8bf56, -744 },
512 { 0x940f4613, 0xae5ed136, 0x871b7795, -740 },
513 { 0xb9131798, 0x99f68584, 0x28e2557b, -737 },
514 { 0xe757dd7e, 0xc07426e5, 0x331aeada, -734 },
515 { 0x9096ea6f, 0x3848984f, 0x3ff0d2c8, -730 },
516 { 0xb4bca50b, 0x065abe63, 0x0fed077a, -727 },
517 { 0xe1ebce4d, 0xc7f16dfb, 0xd3e84959, -724 },
518 { 0x8d3360f0, 0x9cf6e4bd, 0x64712dd7, -720 },
519 { 0xb080392c, 0xc4349dec, 0xbd8d794d, -717 },
520 { 0xdca04777, 0xf541c567, 0xecf0d7a0, -714 },
521 { 0x89e42caa, 0xf9491b60, 0xf41686c4, -710 },
522 { 0xac5d37d5, 0xb79b6239, 0x311c2875, -707 },
523 { 0xd77485cb, 0x25823ac7, 0x7d633293, -704 },
524 { 0x86a8d39e, 0xf77164bc, 0xae5dff9c, -700 },
525 { 0xa8530886, 0xb54dbdeb, 0xd9f57f83, -697 },
526 { 0xd267caa8, 0x62a12d66, 0xd072df63, -694 },
527 { 0x8380dea9, 0x3da4bc60, 0x4247cb9e, -690 },
528 { 0xa4611653, 0x8d0deb78, 0x52d9be85, -687 },
529 { 0xcd795be8, 0x70516656, 0x67902e27, -684 },
530 { 0x806bd971, 0x4632dff6, 0x00ba1cd8, -680 },
531 { 0xa086cfcd, 0x97bf97f3, 0x80e8a40e, -677 },
532 { 0xc8a883c0, 0xfdaf7df0, 0x6122cd12, -674 },
533 { 0xfad2a4b1, 0x3d1b5d6c, 0x796b8057, -671 },
534 { 0x9cc3a6ee, 0xc6311a63, 0xcbe33036, -667 },
535 { 0xc3f490aa, 0x77bd60fc, 0xbedbfc44, -664 },
536 { 0xf4f1b4d5, 0x15acb93b, 0xee92fb55, -661 },
537 { 0x99171105, 0x2d8bf3c5, 0x751bdd15, -657 },
538 { 0xbf5cd546, 0x78eef0b6, 0xd262d45a, -654 },
539 { 0xef340a98, 0x172aace4, 0x86fb8971, -651 },
540 { 0x9580869f, 0x0e7aac0e, 0xd45d35e6, -647 },
541 { 0xbae0a846, 0xd2195712, 0x89748360, -644 },
542 { 0xe998d258, 0x869facd7, 0x2bd1a438, -641 },
543 { 0x91ff8377, 0x5423cc06, 0x7b6306a3, -637 },
544 { 0xb67f6455, 0x292cbf08, 0x1a3bc84c, -634 },
545 { 0xe41f3d6a, 0x7377eeca, 0x20caba5f, -631 },
546 { 0x8e938662, 0x882af53e, 0x547eb47b, -627 },
547 { 0xb23867fb, 0x2a35b28d, 0xe99e619a, -624 },
548 { 0xdec681f9, 0xf4c31f31, 0x6405fa00, -621 },
549 { 0x8b3c113c, 0x38f9f37e, 0xde83bc40, -617 },
550 { 0xae0b158b, 0x4738705e, 0x9624ab50, -614 },
551 { 0xd98ddaee, 0x19068c76, 0x3badd624, -611 },
552 { 0x87f8a8d4, 0xcfa417c9, 0xe54ca5d7, -607 },
553 { 0xa9f6d30a, 0x038d1dbc, 0x5e9fcf4c, -604 },
554 { 0xd47487cc, 0x8470652b, 0x7647c320, -601 },
555 { 0x84c8d4df, 0xd2c63f3b, 0x29ecd9f4, -597 },
556 { 0xa5fb0a17, 0xc777cf09, 0xf4681071, -594 },
557 { 0xcf79cc9d, 0xb955c2cc, 0x7182148d, -591 },
558 { 0x81ac1fe2, 0x93d599bf, 0xc6f14cd8, -587 },
559 { 0xa21727db, 0x38cb002f, 0xb8ada00e, -584 },
560 { 0xca9cf1d2, 0x06fdc03b, 0xa6d90811, -581 },
561 { 0xfd442e46, 0x88bd304a, 0x908f4a16, -578 },
562 { 0x9e4a9cec, 0x15763e2e, 0x9a598e4e, -574 },
563 { 0xc5dd4427, 0x1ad3cdba, 0x40eff1e1, -571 },
564 { 0xf7549530, 0xe188c128, 0xd12bee59, -568 },
565 { 0x9a94dd3e, 0x8cf578b9, 0x82bb74f8, -564 },
566 { 0xc13a148e, 0x3032d6e7, 0xe36a5236, -561 },
567 { 0xf18899b1, 0xbc3f8ca1, 0xdc44e6c3, -558 },
568 { 0x96f5600f, 0x15a7b7e5, 0x29ab103a, -554 },
569 { 0xbcb2b812, 0xdb11a5de, 0x7415d448, -551 },
570 { 0xebdf6617, 0x91d60f56, 0x111b495b, -548 },
571 { 0x936b9fce, 0xbb25c995, 0xcab10dd9, -544 },
572 { 0xb84687c2, 0x69ef3bfb, 0x3d5d514f, -541 },
573 { 0xe65829b3, 0x046b0afa, 0x0cb4a5a3, -538 },
574 { 0x8ff71a0f, 0xe2c2e6dc, 0x47f0e785, -534 },
575 { 0xb3f4e093, 0xdb73a093, 0x59ed2167, -531 },
576 { 0xe0f218b8, 0xd25088b8, 0x306869c1, -528 },
577 { 0x8c974f73, 0x83725573, 0x1e414218, -524 },
578 { 0xafbd2350, 0x644eeacf, 0xe5d1929e, -521 },
579 { 0xdbac6c24, 0x7d62a583, 0xdf45f746, -518 },
580 { 0x894bc396, 0xce5da772, 0x6b8bba8c, -514 },
581 { 0xab9eb47c, 0x81f5114f, 0x066ea92f, -511 },
582 { 0xd686619b, 0xa27255a2, 0xc80a537b, -508 },
583 { 0x8613fd01, 0x45877585, 0xbd06742c, -504 },
584 { 0xa798fc41, 0x96e952e7, 0x2c481138, -501 },
585 { 0xd17f3b51, 0xfca3a7a0, 0xf75a1586, -498 },
586 { 0x82ef8513, 0x3de648c4, 0x9a984d73, -494 },
587 { 0xa3ab6658, 0x0d5fdaf5, 0xc13e60d0, -491 },
588 { 0xcc963fee, 0x10b7d1b3, 0x318df905, -488 },
589 { 0xffbbcfe9, 0x94e5c61f, 0xfdf17746, -485 },
590 { 0x9fd561f1, 0xfd0f9bd3, 0xfeb6ea8b, -481 },
591 { 0xc7caba6e, 0x7c5382c8, 0xfe64a52e, -478 },
592 { 0xf9bd690a, 0x1b68637b, 0x3dfdce7a, -475 },
593 { 0x9c1661a6, 0x51213e2d, 0x06bea10c, -471 },
594 { 0xc31bfa0f, 0xe5698db8, 0x486e494f, -468 },
595 { 0xf3e2f893, 0xdec3f126, 0x5a89dba3, -465 },
596 { 0x986ddb5c, 0x6b3a76b7, 0xf8962946, -461 },
597 { 0xbe895233, 0x86091465, 0xf6bbb397, -458 },
598 { 0xee2ba6c0, 0x678b597f, 0x746aa07d, -455 },
599 { 0x94db4838, 0x40b717ef, 0xa8c2a44e, -451 },
600 { 0xba121a46, 0x50e4ddeb, 0x92f34d62, -448 },
601 { 0xe896a0d7, 0xe51e1566, 0x77b020ba, -445 },
602 { 0x915e2486, 0xef32cd60, 0x0ace1474, -441 },
603 { 0xb5b5ada8, 0xaaff80b8, 0x0d819992, -438 },
604 { 0xe3231912, 0xd5bf60e6, 0x10e1fff6, -435 },
605 { 0x8df5efab, 0xc5979c8f, 0xca8d3ffa, -431 },
606 { 0xb1736b96, 0xb6fd83b3, 0xbd308ff8, -428 },
607 { 0xddd0467c, 0x64bce4a0, 0xac7cb3f6, -425 },
608 { 0x8aa22c0d, 0xbef60ee4, 0x6bcdf07a, -421 },
609 { 0xad4ab711, 0x2eb3929d, 0x86c16c98, -418 },
610 { 0xd89d64d5, 0x7a607744, 0xe871c7bf, -415 },
611 { 0x87625f05, 0x6c7c4a8b, 0x11471cd7, -411 },
612 { 0xa93af6c6, 0xc79b5d2d, 0xd598e40d, -408 },
613 { 0xd389b478, 0x79823479, 0x4aff1d10, -405 },
614 { 0x843610cb, 0x4bf160cb, 0xcedf722a, -401 },
615 { 0xa54394fe, 0x1eedb8fe, 0xc2974eb4, -398 },
616 { 0xce947a3d, 0xa6a9273e, 0x733d2262, -395 },
617 { 0x811ccc66, 0x8829b887, 0x0806357d, -391 },
618 { 0xa163ff80, 0x2a3426a8, 0xca07c2dc, -388 },
619 { 0xc9bcff60, 0x34c13052, 0xfc89b393, -385 },
620 { 0xfc2c3f38, 0x41f17c67, 0xbbac2078, -382 },
621 { 0x9d9ba783, 0x2936edc0, 0xd54b944b, -378 },
622 { 0xc5029163, 0xf384a931, 0x0a9e795e, -375 },
623 { 0xf64335bc, 0xf065d37d, 0x4d4617b5, -372 },
624 { 0x99ea0196, 0x163fa42e, 0x504bced1, -368 },
625 { 0xc06481fb, 0x9bcf8d39, 0xe45ec286, -365 },
626 { 0xf07da27a, 0x82c37088, 0x5d767327, -362 },
627 { 0x964e858c, 0x91ba2655, 0x3a6a07f8, -358 },
628 { 0xbbe226ef, 0xb628afea, 0x890489f7, -355 },
629 { 0xeadab0ab, 0xa3b2dbe5, 0x2b45ac74, -352 },
630 { 0x92c8ae6b, 0x464fc96f, 0x3b0b8bc9, -348 },
631 { 0xb77ada06, 0x17e3bbcb, 0x09ce6ebb, -345 },
632 { 0xe5599087, 0x9ddcaabd, 0xcc420a6a, -342 },
633 { 0x8f57fa54, 0xc2a9eab6, 0x9fa94682, -338 },
634 { 0xb32df8e9, 0xf3546564, 0x47939822, -335 },
635 { 0xdff97724, 0x70297ebd, 0x59787e2b, -332 },
636 { 0x8bfbea76, 0xc619ef36, 0x57eb4edb, -328 },
637 { 0xaefae514, 0x77a06b03, 0xede62292, -325 },
638 { 0xdab99e59, 0x958885c4, 0xe95fab36, -322 },
639 { 0x88b402f7, 0xfd75539b, 0x11dbcb02, -318 },
640 { 0xaae103b5, 0xfcd2a881, 0xd652bdc2, -315 },
641 { 0xd59944a3, 0x7c0752a2, 0x4be76d33, -312 },
642 { 0x857fcae6, 0x2d8493a5, 0x6f70a440, -308 },
643 { 0xa6dfbd9f, 0xb8e5b88e, 0xcb4ccd50, -305 },
644 { 0xd097ad07, 0xa71f26b2, 0x7e2000a4, -302 },
645 { 0x825ecc24, 0xc873782f, 0x8ed40066, -298 },
646 { 0xa2f67f2d, 0xfa90563b, 0x72890080, -295 },
647 { 0xcbb41ef9, 0x79346bca, 0x4f2b40a0, -292 },
648 { 0xfea126b7, 0xd78186bc, 0xe2f610c8, -289 },
649 { 0x9f24b832, 0xe6b0f436, 0x0dd9ca7d, -285 },
650 { 0xc6ede63f, 0xa05d3143, 0x91503d1c, -282 },
651 { 0xf8a95fcf, 0x88747d94, 0x75a44c63, -279 },
652 { 0x9b69dbe1, 0xb548ce7c, 0xc986afbe, -275 },
653 { 0xc24452da, 0x229b021b, 0xfbe85bad, -272 },
654 { 0xf2d56790, 0xab41c2a2, 0xfae27299, -269 },
655 { 0x97c560ba, 0x6b0919a5, 0xdccd879f, -265 },
656 { 0xbdb6b8e9, 0x05cb600f, 0x5400e987, -262 },
657 { 0xed246723, 0x473e3813, 0x290123e9, -259 },
658 { 0x9436c076, 0x0c86e30b, 0xf9a0b672, -255 },
659 { 0xb9447093, 0x8fa89bce, 0xf808e40e, -252 },
660 { 0xe7958cb8, 0x7392c2c2, 0xb60b1d12, -249 },
661 { 0x90bd77f3, 0x483bb9b9, 0xb1c6f22b, -245 },
662 { 0xb4ecd5f0, 0x1a4aa828, 0x1e38aeb6, -242 },
663 { 0xe2280b6c, 0x20dd5232, 0x25c6da63, -239 },
664 { 0x8d590723, 0x948a535f, 0x579c487e, -235 },
665 { 0xb0af48ec, 0x79ace837, 0x2d835a9d, -232 },
666 { 0xdcdb1b27, 0x98182244, 0xf8e43145, -229 },
667 { 0x8a08f0f8, 0xbf0f156b, 0x1b8e9ecb, -225 },
668 { 0xac8b2d36, 0xeed2dac5, 0xe272467e, -222 },
669 { 0xd7adf884, 0xaa879177, 0x5b0ed81d, -219 },
670 { 0x86ccbb52, 0xea94baea, 0x98e94712, -215 },
671 { 0xa87fea27, 0xa539e9a5, 0x3f2398d7, -212 },
672 { 0xd29fe4b1, 0x8e88640e, 0x8eec7f0d, -209 },
673 { 0x83a3eeee, 0xf9153e89, 0x1953cf68, -205 },
674 { 0xa48ceaaa, 0xb75a8e2b, 0x5fa8c342, -202 },
675 { 0xcdb02555, 0x653131b6, 0x3792f412, -199 },
676 { 0x808e1755, 0x5f3ebf11, 0xe2bbd88b, -195 },
677 { 0xa0b19d2a, 0xb70e6ed6, 0x5b6aceae, -192 },
678 { 0xc8de0475, 0x64d20a8b, 0xf245825a, -189 },
679 { 0xfb158592, 0xbe068d2e, 0xeed6e2f0, -186 },
680 { 0x9ced737b, 0xb6c4183d, 0x55464dd6, -182 },
681 { 0xc428d05a, 0xa4751e4c, 0xaa97e14c, -179 },
682 { 0xf5330471, 0x4d9265df, 0xd53dd99f, -176 },
683 { 0x993fe2c6, 0xd07b7fab, 0xe546a803, -172 },
684 { 0xbf8fdb78, 0x849a5f96, 0xde985204, -169 },
685 { 0xef73d256, 0xa5c0f77c, 0x963e6685, -166 },
686 { 0x95a86376, 0x27989aad, 0xdde70013, -162 },
687 { 0xbb127c53, 0xb17ec159, 0x5560c018, -159 },
688 { 0xe9d71b68, 0x9dde71af, 0xaab8f01e, -156 },
689 { 0x92267121, 0x62ab070d, 0xcab39613, -152 },
690 { 0xb6b00d69, 0xbb55c8d1, 0x3d607b97, -149 },
691 { 0xe45c10c4, 0x2a2b3b05, 0x8cb89a7d, -146 },
692 { 0x8eb98a7a, 0x9a5b04e3, 0x77f3608e, -142 },
693 { 0xb267ed19, 0x40f1c61c, 0x55f038b2, -139 },
694 { 0xdf01e85f, 0x912e37a3, 0x6b6c46de, -136 },
695 { 0x8b61313b, 0xbabce2c6, 0x2323ac4b, -132 },
696 { 0xae397d8a, 0xa96c1b77, 0xabec975e, -129 },
697 { 0xd9c7dced, 0x53c72255, 0x96e7bd35, -126 },
698 { 0x881cea14, 0x545c7575, 0x7e50d641, -122 },
699 { 0xaa242499, 0x697392d2, 0xdde50bd1, -119 },
700 { 0xd4ad2dbf, 0xc3d07787, 0x955e4ec6, -116 },
701 { 0x84ec3c97, 0xda624ab4, 0xbd5af13b, -112 },
702 { 0xa6274bbd, 0xd0fadd61, 0xecb1ad8a, -109 },
703 { 0xcfb11ead, 0x453994ba, 0x67de18ed, -106 },
704 { 0x81ceb32c, 0x4b43fcf4, 0x80eacf94, -102 },
705 { 0xa2425ff7, 0x5e14fc31, 0xa1258379, -99 },
706 { 0xcad2f7f5, 0x359a3b3e, 0x096ee458, -96 },
707 { 0xfd87b5f2, 0x8300ca0d, 0x8bca9d6e, -93 },
708 { 0x9e74d1b7, 0x91e07e48, 0x775ea264, -89 },
709 { 0xc6120625, 0x76589dda, 0x95364afe, -86 },
710 { 0xf79687ae, 0xd3eec551, 0x3a83ddbd, -83 },
711 { 0x9abe14cd, 0x44753b52, 0xc4926a96, -79 },
712 { 0xc16d9a00, 0x95928a27, 0x75b7053c, -76 },
713 { 0xf1c90080, 0xbaf72cb1, 0x5324c68b, -73 },
714 { 0x971da050, 0x74da7bee, 0xd3f6fc16, -69 },
715 { 0xbce50864, 0x92111aea, 0x88f4bb1c, -66 },
716 { 0xec1e4a7d, 0xb69561a5, 0x2b31e9e3, -63 },
717 { 0x9392ee8e, 0x921d5d07, 0x3aff322e, -59 },
718 { 0xb877aa32, 0x36a4b449, 0x09befeb9, -56 },
719 { 0xe69594be, 0xc44de15b, 0x4c2ebe68, -53 },
720 { 0x901d7cf7, 0x3ab0acd9, 0x0f9d3701, -49 },
721 { 0xb424dc35, 0x095cd80f, 0x538484c1, -46 },
722 { 0xe12e1342, 0x4bb40e13, 0x2865a5f2, -43 },
723 { 0x8cbccc09, 0x6f5088cb, 0xf93f87b7, -39 },
724 { 0xafebff0b, 0xcb24aafe, 0xf78f69a5, -36 },
725 { 0xdbe6fece, 0xbdedd5be, 0xb573440e, -33 },
726 { 0x89705f41, 0x36b4a597, 0x31680a88, -29 },
727 { 0xabcc7711, 0x8461cefc, 0xfdc20d2b, -26 },
728 { 0xd6bf94d5, 0xe57a42bc, 0x3d329076, -23 },
729 { 0x8637bd05, 0xaf6c69b5, 0xa63f9a49, -19 },
730 { 0xa7c5ac47, 0x1b478423, 0x0fcf80dc, -16 },
731 { 0xd1b71758, 0xe219652b, 0xd3c36113, -13 },
732 { 0x83126e97, 0x8d4fdf3b, 0x645a1cac, -9 },
733 { 0xa3d70a3d, 0x70a3d70a, 0x3d70a3d7, -6 },
734 { 0xcccccccc, 0xcccccccc, 0xcccccccc, -3 },
735 { 0x80000000, 0x00000000, 0x00000000, 1 },
736 { 0xa0000000, 0x00000000, 0x00000000, 4 },
737 { 0xc8000000, 0x00000000, 0x00000000, 7 },
738 { 0xfa000000, 0x00000000, 0x00000000, 10 },
739 { 0x9c400000, 0x00000000, 0x00000000, 14 },
740 { 0xc3500000, 0x00000000, 0x00000000, 17 },
741 { 0xf4240000, 0x00000000, 0x00000000, 20 },
742 { 0x98968000, 0x00000000, 0x00000000, 24 },
743 { 0xbebc2000, 0x00000000, 0x00000000, 27 },
744 { 0xee6b2800, 0x00000000, 0x00000000, 30 },
745 { 0x9502f900, 0x00000000, 0x00000000, 34 },
746 { 0xba43b740, 0x00000000, 0x00000000, 37 },
747 { 0xe8d4a510, 0x00000000, 0x00000000, 40 },
748 { 0x9184e72a, 0x00000000, 0x00000000, 44 },
749 { 0xb5e620f4, 0x80000000, 0x00000000, 47 },
750 { 0xe35fa931, 0xa0000000, 0x00000000, 50 },
751 { 0x8e1bc9bf, 0x04000000, 0x00000000, 54 },
752 { 0xb1a2bc2e, 0xc5000000, 0x00000000, 57 },
753 { 0xde0b6b3a, 0x76400000, 0x00000000, 60 },
754 { 0x8ac72304, 0x89e80000, 0x00000000, 64 },
755 { 0xad78ebc5, 0xac620000, 0x00000000, 67 },
756 { 0xd8d726b7, 0x177a8000, 0x00000000, 70 },
757 { 0x87867832, 0x6eac9000, 0x00000000, 74 },
758 { 0xa968163f, 0x0a57b400, 0x00000000, 77 },
759 { 0xd3c21bce, 0xcceda100, 0x00000000, 80 },
760 { 0x84595161, 0x401484a0, 0x00000000, 84 },
761 { 0xa56fa5b9, 0x9019a5c8, 0x00000000, 87 },
762 { 0xcecb8f27, 0xf4200f3a, 0x00000000, 90 },
763 { 0x813f3978, 0xf8940984, 0x40000000, 94 },
764 { 0xa18f07d7, 0x36b90be5, 0x50000000, 97 },
765 { 0xc9f2c9cd, 0x04674ede, 0xa4000000, 100 },
766 { 0xfc6f7c40, 0x45812296, 0x4d000000, 103 },
767 { 0x9dc5ada8, 0x2b70b59d, 0xf0200000, 107 },
768 { 0xc5371912, 0x364ce305, 0x6c280000, 110 },
769 { 0xf684df56, 0xc3e01bc6, 0xc7320000, 113 },
770 { 0x9a130b96, 0x3a6c115c, 0x3c7f4000, 117 },
771 { 0xc097ce7b, 0xc90715b3, 0x4b9f1000, 120 },
772 { 0xf0bdc21a, 0xbb48db20, 0x1e86d400, 123 },
773 { 0x96769950, 0xb50d88f4, 0x13144480, 127 },
774 { 0xbc143fa4, 0xe250eb31, 0x17d955a0, 130 },
775 { 0xeb194f8e, 0x1ae525fd, 0x5dcfab08, 133 },
776 { 0x92efd1b8, 0xd0cf37be, 0x5aa1cae5, 137 },
777 { 0xb7abc627, 0x050305ad, 0xf14a3d9e, 140 },
778 { 0xe596b7b0, 0xc643c719, 0x6d9ccd05, 143 },
779 { 0x8f7e32ce, 0x7bea5c6f, 0xe4820023, 147 },
780 { 0xb35dbf82, 0x1ae4f38b, 0xdda2802c, 150 },
781 { 0xe0352f62, 0xa19e306e, 0xd50b2037, 153 },
782 { 0x8c213d9d, 0xa502de45, 0x4526f422, 157 },
783 { 0xaf298d05, 0x0e4395d6, 0x9670b12b, 160 },
784 { 0xdaf3f046, 0x51d47b4c, 0x3c0cdd76, 163 },
785 { 0x88d8762b, 0xf324cd0f, 0xa5880a69, 167 },
786 { 0xab0e93b6, 0xefee0053, 0x8eea0d04, 170 },
787 { 0xd5d238a4, 0xabe98068, 0x72a49045, 173 },
788 { 0x85a36366, 0xeb71f041, 0x47a6da2b, 177 },
789 { 0xa70c3c40, 0xa64e6c51, 0x999090b6, 180 },
790 { 0xd0cf4b50, 0xcfe20765, 0xfff4b4e3, 183 },
791 { 0x82818f12, 0x81ed449f, 0xbff8f10e, 187 },
792 { 0xa321f2d7, 0x226895c7, 0xaff72d52, 190 },
793 { 0xcbea6f8c, 0xeb02bb39, 0x9bf4f8a6, 193 },
794 { 0xfee50b70, 0x25c36a08, 0x02f236d0, 196 },
795 { 0x9f4f2726, 0x179a2245, 0x01d76242, 200 },
796 { 0xc722f0ef, 0x9d80aad6, 0x424d3ad2, 203 },
797 { 0xf8ebad2b, 0x84e0d58b, 0xd2e08987, 206 },
798 { 0x9b934c3b, 0x330c8577, 0x63cc55f4, 210 },
799 { 0xc2781f49, 0xffcfa6d5, 0x3cbf6b71, 213 },
800 { 0xf316271c, 0x7fc3908a, 0x8bef464e, 216 },
801 { 0x97edd871, 0xcfda3a56, 0x97758bf0, 220 },
802 { 0xbde94e8e, 0x43d0c8ec, 0x3d52eeed, 223 },
803 { 0xed63a231, 0xd4c4fb27, 0x4ca7aaa8, 226 },
804 { 0x945e455f, 0x24fb1cf8, 0x8fe8caa9, 230 },
805 { 0xb975d6b6, 0xee39e436, 0xb3e2fd53, 233 },
806 { 0xe7d34c64, 0xa9c85d44, 0x60dbbca8, 236 },
807 { 0x90e40fbe, 0xea1d3a4a, 0xbc8955e9, 240 },
808 { 0xb51d13ae, 0xa4a488dd, 0x6babab63, 243 },
809 { 0xe264589a, 0x4dcdab14, 0xc696963c, 246 },
810 { 0x8d7eb760, 0x70a08aec, 0xfc1e1de5, 250 },
811 { 0xb0de6538, 0x8cc8ada8, 0x3b25a55f, 253 },
812 { 0xdd15fe86, 0xaffad912, 0x49ef0eb7, 256 },
813 { 0x8a2dbf14, 0x2dfcc7ab, 0x6e356932, 260 },
814 { 0xacb92ed9, 0x397bf996, 0x49c2c37f, 263 },
815 { 0xd7e77a8f, 0x87daf7fb, 0xdc33745e, 266 },
816 { 0x86f0ac99, 0xb4e8dafd, 0x69a028bb, 270 },
817 { 0xa8acd7c0, 0x222311bc, 0xc40832ea, 273 },
818 { 0xd2d80db0, 0x2aabd62b, 0xf50a3fa4, 276 },
819 { 0x83c7088e, 0x1aab65db, 0x792667c6, 280 },
820 { 0xa4b8cab1, 0xa1563f52, 0x577001b8, 283 },
821 { 0xcde6fd5e, 0x09abcf26, 0xed4c0226, 286 },
822 { 0x80b05e5a, 0xc60b6178, 0x544f8158, 290 },
823 { 0xa0dc75f1, 0x778e39d6, 0x696361ae, 293 },
824 { 0xc913936d, 0xd571c84c, 0x03bc3a19, 296 },
825 { 0xfb587849, 0x4ace3a5f, 0x04ab48a0, 299 },
826 { 0x9d174b2d, 0xcec0e47b, 0x62eb0d64, 303 },
827 { 0xc45d1df9, 0x42711d9a, 0x3ba5d0bd, 306 },
828 { 0xf5746577, 0x930d6500, 0xca8f44ec, 309 },
829 { 0x9968bf6a, 0xbbe85f20, 0x7e998b13, 313 },
830 { 0xbfc2ef45, 0x6ae276e8, 0x9e3fedd8, 316 },
831 { 0xefb3ab16, 0xc59b14a2, 0xc5cfe94e, 319 },
832 { 0x95d04aee, 0x3b80ece5, 0xbba1f1d1, 323 },
833 { 0xbb445da9, 0xca61281f, 0x2a8a6e45, 326 },
834 { 0xea157514, 0x3cf97226, 0xf52d09d7, 329 },
835 { 0x924d692c, 0xa61be758, 0x593c2626, 333 },
836 { 0xb6e0c377, 0xcfa2e12e, 0x6f8b2fb0, 336 },
837 { 0xe498f455, 0xc38b997a, 0x0b6dfb9c, 339 },
838 { 0x8edf98b5, 0x9a373fec, 0x4724bd41, 343 },
839 { 0xb2977ee3, 0x00c50fe7, 0x58edec91, 346 },
840 { 0xdf3d5e9b, 0xc0f653e1, 0x2f2967b6, 349 },
841 { 0x8b865b21, 0x5899f46c, 0xbd79e0d2, 353 },
842 { 0xae67f1e9, 0xaec07187, 0xecd85906, 356 },
843 { 0xda01ee64, 0x1a708de9, 0xe80e6f48, 359 },
844 { 0x884134fe, 0x908658b2, 0x3109058d, 363 },
845 { 0xaa51823e, 0x34a7eede, 0xbd4b46f0, 366 },
846 { 0xd4e5e2cd, 0xc1d1ea96, 0x6c9e18ac, 369 },
847 { 0x850fadc0, 0x9923329e, 0x03e2cf6b, 373 },
848 { 0xa6539930, 0xbf6bff45, 0x84db8346, 376 },
849 { 0xcfe87f7c, 0xef46ff16, 0xe6126418, 379 },
850 { 0x81f14fae, 0x158c5f6e, 0x4fcb7e8f, 383 },
851 { 0xa26da399, 0x9aef7749, 0xe3be5e33, 386 },
852 { 0xcb090c80, 0x01ab551c, 0x5cadf5bf, 389 },
853 { 0xfdcb4fa0, 0x02162a63, 0x73d9732f, 392 },
854 { 0x9e9f11c4, 0x014dda7e, 0x2867e7fd, 396 },
855 { 0xc646d635, 0x01a1511d, 0xb281e1fd, 399 },
856 { 0xf7d88bc2, 0x4209a565, 0x1f225a7c, 402 },
857 { 0x9ae75759, 0x6946075f, 0x3375788d, 406 },
858 { 0xc1a12d2f, 0xc3978937, 0x0052d6b1, 409 },
859 { 0xf209787b, 0xb47d6b84, 0xc0678c5d, 412 },
860 { 0x9745eb4d, 0x50ce6332, 0xf840b7ba, 416 },
861 { 0xbd176620, 0xa501fbff, 0xb650e5a9, 419 },
862 { 0xec5d3fa8, 0xce427aff, 0xa3e51f13, 422 },
863 { 0x93ba47c9, 0x80e98cdf, 0xc66f336c, 426 },
864 { 0xb8a8d9bb, 0xe123f017, 0xb80b0047, 429 },
865 { 0xe6d3102a, 0xd96cec1d, 0xa60dc059, 432 },
866 { 0x9043ea1a, 0xc7e41392, 0x87c89837, 436 },
867 { 0xb454e4a1, 0x79dd1877, 0x29babe45, 439 },
868 { 0xe16a1dc9, 0xd8545e94, 0xf4296dd6, 442 },
869 { 0x8ce2529e, 0x2734bb1d, 0x1899e4a6, 446 },
870 { 0xb01ae745, 0xb101e9e4, 0x5ec05dcf, 449 },
871 { 0xdc21a117, 0x1d42645d, 0x76707543, 452 },
872 { 0x899504ae, 0x72497eba, 0x6a06494a, 456 },
873 { 0xabfa45da, 0x0edbde69, 0x0487db9d, 459 },
874 { 0xd6f8d750, 0x9292d603, 0x45a9d284, 462 },
875 { 0x865b8692, 0x5b9bc5c2, 0x0b8a2392, 466 },
876 { 0xa7f26836, 0xf282b732, 0x8e6cac77, 469 },
877 { 0xd1ef0244, 0xaf2364ff, 0x3207d795, 472 },
878 { 0x8335616a, 0xed761f1f, 0x7f44e6bd, 476 },
879 { 0xa402b9c5, 0xa8d3a6e7, 0x5f16206c, 479 },
880 { 0xcd036837, 0x130890a1, 0x36dba887, 482 },
881 { 0x80222122, 0x6be55a64, 0xc2494954, 486 },
882 { 0xa02aa96b, 0x06deb0fd, 0xf2db9baa, 489 },
883 { 0xc83553c5, 0xc8965d3d, 0x6f928294, 492 },
884 { 0xfa42a8b7, 0x3abbf48c, 0xcb772339, 495 },
885 { 0x9c69a972, 0x84b578d7, 0xff2a7604, 499 },
886 { 0xc38413cf, 0x25e2d70d, 0xfef51385, 502 },
887 { 0xf46518c2, 0xef5b8cd1, 0x7eb25866, 505 },
888 { 0x98bf2f79, 0xd5993802, 0xef2f773f, 509 },
889 { 0xbeeefb58, 0x4aff8603, 0xaafb550f, 512 },
890 { 0xeeaaba2e, 0x5dbf6784, 0x95ba2a53, 515 },
891 { 0x952ab45c, 0xfa97a0b2, 0xdd945a74, 519 },
892 { 0xba756174, 0x393d88df, 0x94f97111, 522 },
893 { 0xe912b9d1, 0x478ceb17, 0x7a37cd56, 525 },
894 { 0x91abb422, 0xccb812ee, 0xac62e055, 529 },
895 { 0xb616a12b, 0x7fe617aa, 0x577b986b, 532 },
896 { 0xe39c4976, 0x5fdf9d94, 0xed5a7e85, 535 },
897 { 0x8e41ade9, 0xfbebc27d, 0x14588f13, 539 },
898 { 0xb1d21964, 0x7ae6b31c, 0x596eb2d8, 542 },
899 { 0xde469fbd, 0x99a05fe3, 0x6fca5f8e, 545 },
900 { 0x8aec23d6, 0x80043bee, 0x25de7bb9, 549 },
901 { 0xada72ccc, 0x20054ae9, 0xaf561aa7, 552 },
902 { 0xd910f7ff, 0x28069da4, 0x1b2ba151, 555 },
903 { 0x87aa9aff, 0x79042286, 0x90fb44d2, 559 },
904 { 0xa99541bf, 0x57452b28, 0x353a1607, 562 },
905 { 0xd3fa922f, 0x2d1675f2, 0x42889b89, 565 },
906 { 0x847c9b5d, 0x7c2e09b7, 0x69956135, 569 },
907 { 0xa59bc234, 0xdb398c25, 0x43fab983, 572 },
908 { 0xcf02b2c2, 0x1207ef2e, 0x94f967e4, 575 },
909 { 0x8161afb9, 0x4b44f57d, 0x1d1be0ee, 579 },
910 { 0xa1ba1ba7, 0x9e1632dc, 0x6462d92a, 582 },
911 { 0xca28a291, 0x859bbf93, 0x7d7b8f75, 585 },
912 { 0xfcb2cb35, 0xe702af78, 0x5cda7352, 588 },
913 { 0x9defbf01, 0xb061adab, 0x3a088813, 592 },
914 { 0xc56baec2, 0x1c7a1916, 0x088aaa18, 595 },
915 { 0xf6c69a72, 0xa3989f5b, 0x8aad549e, 598 },
916 { 0x9a3c2087, 0xa63f6399, 0x36ac54e2, 602 },
917 { 0xc0cb28a9, 0x8fcf3c7f, 0x84576a1b, 605 },
918 { 0xf0fdf2d3, 0xf3c30b9f, 0x656d44a2, 608 },
919 { 0x969eb7c4, 0x7859e743, 0x9f644ae5, 612 },
920 { 0xbc4665b5, 0x96706114, 0x873d5d9f, 615 },
921 { 0xeb57ff22, 0xfc0c7959, 0xa90cb506, 618 },
922 { 0x9316ff75, 0xdd87cbd8, 0x09a7f124, 622 },
923 { 0xb7dcbf53, 0x54e9bece, 0x0c11ed6d, 625 },
924 { 0xe5d3ef28, 0x2a242e81, 0x8f1668c8, 628 },
925 { 0x8fa47579, 0x1a569d10, 0xf96e017d, 632 },
926 { 0xb38d92d7, 0x60ec4455, 0x37c981dc, 635 },
927 { 0xe070f78d, 0x3927556a, 0x85bbe253, 638 },
928 { 0x8c469ab8, 0x43b89562, 0x93956d74, 642 },
929 { 0xaf584166, 0x54a6babb, 0x387ac8d1, 645 },
930 { 0xdb2e51bf, 0xe9d0696a, 0x06997b05, 648 },
931 { 0x88fcf317, 0xf22241e2, 0x441fece3, 652 },
932 { 0xab3c2fdd, 0xeeaad25a, 0xd527e81c, 655 },
933 { 0xd60b3bd5, 0x6a5586f1, 0x8a71e223, 658 },
934 { 0x85c70565, 0x62757456, 0xf6872d56, 662 },
935 { 0xa738c6be, 0xbb12d16c, 0xb428f8ac, 665 },
936 { 0xd106f86e, 0x69d785c7, 0xe13336d7, 668 },
937 { 0x82a45b45, 0x0226b39c, 0xecc00246, 672 },
938 { 0xa34d7216, 0x42b06084, 0x27f002d7, 675 },
939 { 0xcc20ce9b, 0xd35c78a5, 0x31ec038d, 678 },
940 { 0xff290242, 0xc83396ce, 0x7e670471, 681 },
941 { 0x9f79a169, 0xbd203e41, 0x0f0062c6, 685 },
942 { 0xc75809c4, 0x2c684dd1, 0x52c07b78, 688 },
943 { 0xf92e0c35, 0x37826145, 0xa7709a56, 691 },
944 { 0x9bbcc7a1, 0x42b17ccb, 0x88a66076, 695 },
945 { 0xc2abf989, 0x935ddbfe, 0x6acff893, 698 },
946 { 0xf356f7eb, 0xf83552fe, 0x0583f6b8, 701 },
947 { 0x98165af3, 0x7b2153de, 0xc3727a33, 705 },
948 { 0xbe1bf1b0, 0x59e9a8d6, 0x744f18c0, 708 },
949 { 0xeda2ee1c, 0x7064130c, 0x1162def0, 711 },
950 { 0x9485d4d1, 0xc63e8be7, 0x8addcb56, 715 },
951 { 0xb9a74a06, 0x37ce2ee1, 0x6d953e2b, 718 },
952 { 0xe8111c87, 0xc5c1ba99, 0xc8fa8db6, 721 },
953 { 0x910ab1d4, 0xdb9914a0, 0x1d9c9892, 725 },
954 { 0xb54d5e4a, 0x127f59c8, 0x2503beb6, 728 },
955 { 0xe2a0b5dc, 0x971f303a, 0x2e44ae64, 731 },
956 { 0x8da471a9, 0xde737e24, 0x5ceaecfe, 735 },
957 { 0xb10d8e14, 0x56105dad, 0x7425a83e, 738 },
958 { 0xdd50f199, 0x6b947518, 0xd12f124e, 741 },
959 { 0x8a5296ff, 0xe33cc92f, 0x82bd6b70, 745 },
960 { 0xace73cbf, 0xdc0bfb7b, 0x636cc64d, 748 },
961 { 0xd8210bef, 0xd30efa5a, 0x3c47f7e0, 751 },
962 { 0x8714a775, 0xe3e95c78, 0x65acfaec, 755 },
963 { 0xa8d9d153, 0x5ce3b396, 0x7f1839a7, 758 },
964 { 0xd31045a8, 0x341ca07c, 0x1ede4811, 761 },
965 { 0x83ea2b89, 0x2091e44d, 0x934aed0a, 765 },
966 { 0xa4e4b66b, 0x68b65d60, 0xf81da84d, 768 },
967 { 0xce1de406, 0x42e3f4b9, 0x36251260, 771 },
968 { 0x80d2ae83, 0xe9ce78f3, 0xc1d72b7c, 775 },
969 { 0xa1075a24, 0xe4421730, 0xb24cf65b, 778 },
970 { 0xc94930ae, 0x1d529cfc, 0xdee033f2, 781 },
971 { 0xfb9b7cd9, 0xa4a7443c, 0x169840ef, 784 },
972 { 0x9d412e08, 0x06e88aa5, 0x8e1f2895, 788 },
973 { 0xc491798a, 0x08a2ad4e, 0xf1a6f2ba, 791 },
974 { 0xf5b5d7ec, 0x8acb58a2, 0xae10af69, 794 },
975 { 0x9991a6f3, 0xd6bf1765, 0xacca6da1, 798 },
976 { 0xbff610b0, 0xcc6edd3f, 0x17fd090a, 801 },
977 { 0xeff394dc, 0xff8a948e, 0xddfc4b4c, 804 },
978 { 0x95f83d0a, 0x1fb69cd9, 0x4abdaf10, 808 },
979 { 0xbb764c4c, 0xa7a4440f, 0x9d6d1ad4, 811 },
980 { 0xea53df5f, 0xd18d5513, 0x84c86189, 814 },
981 { 0x92746b9b, 0xe2f8552c, 0x32fd3cf5, 818 },
982 { 0xb7118682, 0xdbb66a77, 0x3fbc8c33, 821 },
983 { 0xe4d5e823, 0x92a40515, 0x0fabaf3f, 824 },
984 { 0x8f05b116, 0x3ba6832d, 0x29cb4d87, 828 },
985 { 0xb2c71d5b, 0xca9023f8, 0x743e20e9, 831 },
986 { 0xdf78e4b2, 0xbd342cf6, 0x914da924, 834 },
987 { 0x8bab8eef, 0xb6409c1a, 0x1ad089b6, 838 },
988 { 0xae9672ab, 0xa3d0c320, 0xa184ac24, 841 },
989 { 0xda3c0f56, 0x8cc4f3e8, 0xc9e5d72d, 844 },
990 { 0x88658996, 0x17fb1871, 0x7e2fa67c, 848 },
991 { 0xaa7eebfb, 0x9df9de8d, 0xddbb901b, 851 },
992 { 0xd51ea6fa, 0x85785631, 0x552a7422, 854 },
993 { 0x8533285c, 0x936b35de, 0xd53a8895, 858 },
994 { 0xa67ff273, 0xb8460356, 0x8a892aba, 861 },
995 { 0xd01fef10, 0xa657842c, 0x2d2b7569, 864 },
996 { 0x8213f56a, 0x67f6b29b, 0x9c3b2962, 868 },
997 { 0xa298f2c5, 0x01f45f42, 0x8349f3ba, 871 },
998 { 0xcb3f2f76, 0x42717713, 0x241c70a9, 874 },
999 { 0xfe0efb53, 0xd30dd4d7, 0xed238cd3, 877 },
1000 { 0x9ec95d14, 0x63e8a506, 0xf4363804, 881 },
1001 { 0xc67bb459, 0x7ce2ce48, 0xb143c605, 884 },
1002 { 0xf81aa16f, 0xdc1b81da, 0xdd94b786, 887 },
1003 { 0x9b10a4e5, 0xe9913128, 0xca7cf2b4, 891 },
1004 { 0xc1d4ce1f, 0x63f57d72, 0xfd1c2f61, 894 },
1005 { 0xf24a01a7, 0x3cf2dccf, 0xbc633b39, 897 },
1006 { 0x976e4108, 0x8617ca01, 0xd5be0503, 901 },
1007 { 0xbd49d14a, 0xa79dbc82, 0x4b2d8644, 904 },
1008 { 0xec9c459d, 0x51852ba2, 0xddf8e7d6, 907 },
1009 { 0x93e1ab82, 0x52f33b45, 0xcabb90e5, 911 },
1010 { 0xb8da1662, 0xe7b00a17, 0x3d6a751f, 914 },
1011 { 0xe7109bfb, 0xa19c0c9d, 0x0cc51267, 917 },
1012 { 0x906a617d, 0x450187e2, 0x27fb2b80, 921 },
1013 { 0xb484f9dc, 0x9641e9da, 0xb1f9f660, 924 },
1014 { 0xe1a63853, 0xbbd26451, 0x5e7873f8, 927 },
1015 { 0x8d07e334, 0x55637eb2, 0xdb0b487b, 931 },
1016 { 0xb049dc01, 0x6abc5e5f, 0x91ce1a9a, 934 },
1017 { 0xdc5c5301, 0xc56b75f7, 0x7641a140, 937 },
1018 { 0x89b9b3e1, 0x1b6329ba, 0xa9e904c8, 941 },
1019 { 0xac2820d9, 0x623bf429, 0x546345fa, 944 },
1020 { 0xd732290f, 0xbacaf133, 0xa97c1779, 947 },
1021 { 0x867f59a9, 0xd4bed6c0, 0x49ed8eab, 951 },
1022 { 0xa81f3014, 0x49ee8c70, 0x5c68f256, 954 },
1023 { 0xd226fc19, 0x5c6a2f8c, 0x73832eec, 957 },
1024 { 0x83585d8f, 0xd9c25db7, 0xc831fd53, 961 },
1025 { 0xa42e74f3, 0xd032f525, 0xba3e7ca8, 964 },
1026 { 0xcd3a1230, 0xc43fb26f, 0x28ce1bd2, 967 },
1027 { 0x80444b5e, 0x7aa7cf85, 0x7980d163, 971 },
1028 { 0xa0555e36, 0x1951c366, 0xd7e105bc, 974 },
1029 { 0xc86ab5c3, 0x9fa63440, 0x8dd9472b, 977 },
1030 { 0xfa856334, 0x878fc150, 0xb14f98f6, 980 },
1031 { 0x9c935e00, 0xd4b9d8d2, 0x6ed1bf9a, 984 },
1032 { 0xc3b83581, 0x09e84f07, 0x0a862f80, 987 },
1033 { 0xf4a642e1, 0x4c6262c8, 0xcd27bb61, 990 },
1034 { 0x98e7e9cc, 0xcfbd7dbd, 0x8038d51c, 994 },
1035 { 0xbf21e440, 0x03acdd2c, 0xe0470a63, 997 },
1036 { 0xeeea5d50, 0x04981478, 0x1858ccfc, 1000 },
1037 { 0x95527a52, 0x02df0ccb, 0x0f37801e, 1004 },
1038 { 0xbaa718e6, 0x8396cffd, 0xd3056025, 1007 },
1039 { 0xe950df20, 0x247c83fd, 0x47c6b82e, 1010 },
1040 { 0x91d28b74, 0x16cdd27e, 0x4cdc331d, 1014 },
1041 { 0xb6472e51, 0x1c81471d, 0xe0133fe4, 1017 },
1042 { 0xe3d8f9e5, 0x63a198e5, 0x58180fdd, 1020 },
1043 { 0x8e679c2f, 0x5e44ff8f, 0x570f09ea, 1024 },
1044 { 0xb201833b, 0x35d63f73, 0x2cd2cc65, 1027 },
1045 { 0xde81e40a, 0x034bcf4f, 0xf8077f7e, 1030 },
1046 { 0x8b112e86, 0x420f6191, 0xfb04afaf, 1034 },
1047 { 0xadd57a27, 0xd29339f6, 0x79c5db9a, 1037 },
1048 { 0xd94ad8b1, 0xc7380874, 0x18375281, 1040 },
1049 { 0x87cec76f, 0x1c830548, 0x8f229391, 1044 },
1050 { 0xa9c2794a, 0xe3a3c69a, 0xb2eb3875, 1047 },
1051 { 0xd433179d, 0x9c8cb841, 0x5fa60692, 1050 },
1052 { 0x849feec2, 0x81d7f328, 0xdbc7c41b, 1054 },
1053 { 0xa5c7ea73, 0x224deff3, 0x12b9b522, 1057 },
1054 { 0xcf39e50f, 0xeae16bef, 0xd768226b, 1060 },
1055 { 0x81842f29, 0xf2cce375, 0xe6a11583, 1064 },
1056 { 0xa1e53af4, 0x6f801c53, 0x60495ae3, 1067 },
1057 { 0xca5e89b1, 0x8b602368, 0x385bb19c, 1070 },
1058 { 0xfcf62c1d, 0xee382c42, 0x46729e03, 1073 },
1059 { 0x9e19db92, 0xb4e31ba9, 0x6c07a2c2, 1077 }
1061 static short int Lhint
[2098] = {
1062 /*18,*/19, 19, 19, 19, 20, 20, 20, 21, 21,
1063 21, 22, 22, 22, 23, 23, 23, 23, 24, 24,
1064 24, 25, 25, 25, 26, 26, 26, 26, 27, 27,
1065 27, 28, 28, 28, 29, 29, 29, 29, 30, 30,
1066 30, 31, 31, 31, 32, 32, 32, 32, 33, 33,
1067 33, 34, 34, 34, 35, 35, 35, 35, 36, 36,
1068 36, 37, 37, 37, 38, 38, 38, 38, 39, 39,
1069 39, 40, 40, 40, 41, 41, 41, 41, 42, 42,
1070 42, 43, 43, 43, 44, 44, 44, 44, 45, 45,
1071 45, 46, 46, 46, 47, 47, 47, 47, 48, 48,
1072 48, 49, 49, 49, 50, 50, 50, 51, 51, 51,
1073 51, 52, 52, 52, 53, 53, 53, 54, 54, 54,
1074 54, 55, 55, 55, 56, 56, 56, 57, 57, 57,
1075 57, 58, 58, 58, 59, 59, 59, 60, 60, 60,
1076 60, 61, 61, 61, 62, 62, 62, 63, 63, 63,
1077 63, 64, 64, 64, 65, 65, 65, 66, 66, 66,
1078 66, 67, 67, 67, 68, 68, 68, 69, 69, 69,
1079 69, 70, 70, 70, 71, 71, 71, 72, 72, 72,
1080 72, 73, 73, 73, 74, 74, 74, 75, 75, 75,
1081 75, 76, 76, 76, 77, 77, 77, 78, 78, 78,
1082 78, 79, 79, 79, 80, 80, 80, 81, 81, 81,
1083 82, 82, 82, 82, 83, 83, 83, 84, 84, 84,
1084 85, 85, 85, 85, 86, 86, 86, 87, 87, 87,
1085 88, 88, 88, 88, 89, 89, 89, 90, 90, 90,
1086 91, 91, 91, 91, 92, 92, 92, 93, 93, 93,
1087 94, 94, 94, 94, 95, 95, 95, 96, 96, 96,
1088 97, 97, 97, 97, 98, 98, 98, 99, 99, 99,
1089 100, 100, 100, 100, 101, 101, 101, 102, 102, 102,
1090 103, 103, 103, 103, 104, 104, 104, 105, 105, 105,
1091 106, 106, 106, 106, 107, 107, 107, 108, 108, 108,
1092 109, 109, 109, 110, 110, 110, 110, 111, 111, 111,
1093 112, 112, 112, 113, 113, 113, 113, 114, 114, 114,
1094 115, 115, 115, 116, 116, 116, 116, 117, 117, 117,
1095 118, 118, 118, 119, 119, 119, 119, 120, 120, 120,
1096 121, 121, 121, 122, 122, 122, 122, 123, 123, 123,
1097 124, 124, 124, 125, 125, 125, 125, 126, 126, 126,
1098 127, 127, 127, 128, 128, 128, 128, 129, 129, 129,
1099 130, 130, 130, 131, 131, 131, 131, 132, 132, 132,
1100 133, 133, 133, 134, 134, 134, 134, 135, 135, 135,
1101 136, 136, 136, 137, 137, 137, 137, 138, 138, 138,
1102 139, 139, 139, 140, 140, 140, 141, 141, 141, 141,
1103 142, 142, 142, 143, 143, 143, 144, 144, 144, 144,
1104 145, 145, 145, 146, 146, 146, 147, 147, 147, 147,
1105 148, 148, 148, 149, 149, 149, 150, 150, 150, 150,
1106 151, 151, 151, 152, 152, 152, 153, 153, 153, 153,
1107 154, 154, 154, 155, 155, 155, 156, 156, 156, 156,
1108 157, 157, 157, 158, 158, 158, 159, 159, 159, 159,
1109 160, 160, 160, 161, 161, 161, 162, 162, 162, 162,
1110 163, 163, 163, 164, 164, 164, 165, 165, 165, 165,
1111 166, 166, 166, 167, 167, 167, 168, 168, 168, 169,
1112 169, 169, 169, 170, 170, 170, 171, 171, 171, 172,
1113 172, 172, 172, 173, 173, 173, 174, 174, 174, 175,
1114 175, 175, 175, 176, 176, 176, 177, 177, 177, 178,
1115 178, 178, 178, 179, 179, 179, 180, 180, 180, 181,
1116 181, 181, 181, 182, 182, 182, 183, 183, 183, 184,
1117 184, 184, 184, 185, 185, 185, 186, 186, 186, 187,
1118 187, 187, 187, 188, 188, 188, 189, 189, 189, 190,
1119 190, 190, 190, 191, 191, 191, 192, 192, 192, 193,
1120 193, 193, 193, 194, 194, 194, 195, 195, 195, 196,
1121 196, 196, 197, 197, 197, 197, 198, 198, 198, 199,
1122 199, 199, 200, 200, 200, 200, 201, 201, 201, 202,
1123 202, 202, 203, 203, 203, 203, 204, 204, 204, 205,
1124 205, 205, 206, 206, 206, 206, 207, 207, 207, 208,
1125 208, 208, 209, 209, 209, 209, 210, 210, 210, 211,
1126 211, 211, 212, 212, 212, 212, 213, 213, 213, 214,
1127 214, 214, 215, 215, 215, 215, 216, 216, 216, 217,
1128 217, 217, 218, 218, 218, 218, 219, 219, 219, 220,
1129 220, 220, 221, 221, 221, 221, 222, 222, 222, 223,
1130 223, 223, 224, 224, 224, 224, 225, 225, 225, 226,
1131 226, 226, 227, 227, 227, 228, 228, 228, 228, 229,
1132 229, 229, 230, 230, 230, 231, 231, 231, 231, 232,
1133 232, 232, 233, 233, 233, 234, 234, 234, 234, 235,
1134 235, 235, 236, 236, 236, 237, 237, 237, 237, 238,
1135 238, 238, 239, 239, 239, 240, 240, 240, 240, 241,
1136 241, 241, 242, 242, 242, 243, 243, 243, 243, 244,
1137 244, 244, 245, 245, 245, 246, 246, 246, 246, 247,
1138 247, 247, 248, 248, 248, 249, 249, 249, 249, 250,
1139 250, 250, 251, 251, 251, 252, 252, 252, 252, 253,
1140 253, 253, 254, 254, 254, 255, 255, 255, 256, 256,
1141 256, 256, 257, 257, 257, 258, 258, 258, 259, 259,
1142 259, 259, 260, 260, 260, 261, 261, 261, 262, 262,
1143 262, 262, 263, 263, 263, 264, 264, 264, 265, 265,
1144 265, 265, 266, 266, 266, 267, 267, 267, 268, 268,
1145 268, 268, 269, 269, 269, 270, 270, 270, 271, 271,
1146 271, 271, 272, 272, 272, 273, 273, 273, 274, 274,
1147 274, 274, 275, 275, 275, 276, 276, 276, 277, 277,
1148 277, 277, 278, 278, 278, 279, 279, 279, 280, 280,
1149 280, 280, 281, 281, 281, 282, 282, 282, 283, 283,
1150 283, 283, 284, 284, 284, 285, 285, 285, 286, 286,
1151 286, 287, 287, 287, 287, 288, 288, 288, 289, 289,
1152 289, 290, 290, 290, 290, 291, 291, 291, 292, 292,
1153 292, 293, 293, 293, 293, 294, 294, 294, 295, 295,
1154 295, 296, 296, 296, 296, 297, 297, 297, 298, 298,
1155 298, 299, 299, 299, 299, 300, 300, 300, 301, 301,
1156 301, 302, 302, 302, 302, 303, 303, 303, 304, 304,
1157 304, 305, 305, 305, 305, 306, 306, 306, 307, 307,
1158 307, 308, 308, 308, 308, 309, 309, 309, 310, 310,
1159 310, 311, 311, 311, 311, 312, 312, 312, 313, 313,
1160 313, 314, 314, 314, 315, 315, 315, 315, 316, 316,
1161 316, 317, 317, 317, 318, 318, 318, 318, 319, 319,
1162 319, 320, 320, 320, 321, 321, 321, 321, 322, 322,
1163 322, 323, 323, 323, 324, 324, 324, 324, 325, 325,
1164 325, 326, 326, 326, 327, 327, 327, 327, 328, 328,
1165 328, 329, 329, 329, 330, 330, 330, 330, 331, 331,
1166 331, 332, 332, 332, 333, 333, 333, 333, 334, 334,
1167 334, 335, 335, 335, 336, 336, 336, 336, 337, 337,
1168 337, 338, 338, 338, 339, 339, 339, 339, 340, 340,
1169 340, 341, 341, 341, 342, 342, 342, 342, 343, 343,
1170 343, 344, 344, 344, 345, 345, 345, 346, 346, 346,
1171 346, 347, 347, 347, 348, 348, 348, 349, 349, 349,
1172 349, 350, 350, 350, 351, 351, 351, 352, 352, 352,
1173 352, 353, 353, 353, 354, 354, 354, 355, 355, 355,
1174 355, 356, 356, 356, 357, 357, 357, 358, 358, 358,
1175 358, 359, 359, 359, 360, 360, 360, 361, 361, 361,
1176 361, 362, 362, 362, 363, 363, 363, 364, 364, 364,
1177 364, 365, 365, 365, 366, 366, 366, 367, 367, 367,
1178 367, 368, 368, 368, 369, 369, 369, 370, 370, 370,
1179 370, 371, 371, 371, 372, 372, 372, 373, 373, 373,
1180 374, 374, 374, 374, 375, 375, 375, 376, 376, 376,
1181 377, 377, 377, 377, 378, 378, 378, 379, 379, 379,
1182 380, 380, 380, 380, 381, 381, 381, 382, 382, 382,
1183 383, 383, 383, 383, 384, 384, 384, 385, 385, 385,
1184 386, 386, 386, 386, 387, 387, 387, 388, 388, 388,
1185 389, 389, 389, 389, 390, 390, 390, 391, 391, 391,
1186 392, 392, 392, 392, 393, 393, 393, 394, 394, 394,
1187 395, 395, 395, 395, 396, 396, 396, 397, 397, 397,
1188 398, 398, 398, 398, 399, 399, 399, 400, 400, 400,
1189 401, 401, 401, 402, 402, 402, 402, 403, 403, 403,
1190 404, 404, 404, 405, 405, 405, 405, 406, 406, 406,
1191 407, 407, 407, 408, 408, 408, 408, 409, 409, 409,
1192 410, 410, 410, 411, 411, 411, 411, 412, 412, 412,
1193 413, 413, 413, 414, 414, 414, 414, 415, 415, 415,
1194 416, 416, 416, 417, 417, 417, 417, 418, 418, 418,
1195 419, 419, 419, 420, 420, 420, 420, 421, 421, 421,
1196 422, 422, 422, 423, 423, 423, 423, 424, 424, 424,
1197 425, 425, 425, 426, 426, 426, 426, 427, 427, 427,
1198 428, 428, 428, 429, 429, 429, 429, 430, 430, 430,
1199 431, 431, 431, 432, 432, 432, 433, 433, 433, 433,
1200 434, 434, 434, 435, 435, 435, 436, 436, 436, 436,
1201 437, 437, 437, 438, 438, 438, 439, 439, 439, 439,
1202 440, 440, 440, 441, 441, 441, 442, 442, 442, 442,
1203 443, 443, 443, 444, 444, 444, 445, 445, 445, 445,
1204 446, 446, 446, 447, 447, 447, 448, 448, 448, 448,
1205 449, 449, 449, 450, 450, 450, 451, 451, 451, 451,
1206 452, 452, 452, 453, 453, 453, 454, 454, 454, 454,
1207 455, 455, 455, 456, 456, 456, 457, 457, 457, 457,
1208 458, 458, 458, 459, 459, 459, 460, 460, 460, 461,
1209 461, 461, 461, 462, 462, 462, 463, 463, 463, 464,
1210 464, 464, 464, 465, 465, 465, 466, 466, 466, 467,
1211 467, 467, 467, 468, 468, 468, 469, 469, 469, 470,
1212 470, 470, 470, 471, 471, 471, 472, 472, 472, 473,
1213 473, 473, 473, 474, 474, 474, 475, 475, 475, 476,
1214 476, 476, 476, 477, 477, 477, 478, 478, 478, 479,
1215 479, 479, 479, 480, 480, 480, 481, 481, 481, 482,
1216 482, 482, 482, 483, 483, 483, 484, 484, 484, 485,
1217 485, 485, 485, 486, 486, 486, 487, 487, 487, 488,
1218 488, 488, 488, 489, 489, 489, 490, 490, 490, 491,
1219 491, 491, 492, 492, 492, 492, 493, 493, 493, 494,
1220 494, 494, 495, 495, 495, 495, 496, 496, 496, 497,
1221 497, 497, 498, 498, 498, 498, 499, 499, 499, 500,
1222 500, 500, 501, 501, 501, 501, 502, 502, 502, 503,
1223 503, 503, 504, 504, 504, 504, 505, 505, 505, 506,
1224 506, 506, 507, 507, 507, 507, 508, 508, 508, 509,
1225 509, 509, 510, 510, 510, 510, 511, 511, 511, 512,
1226 512, 512, 513, 513, 513, 513, 514, 514, 514, 515,
1227 515, 515, 516, 516, 516, 516, 517, 517, 517, 518,
1228 518, 518, 519, 519, 519, 520, 520, 520, 520, 521,
1229 521, 521, 522, 522, 522, 523, 523, 523, 523, 524,
1230 524, 524, 525, 525, 525, 526, 526, 526, 526, 527,
1231 527, 527, 528, 528, 528, 529, 529, 529, 529, 530,
1232 530, 530, 531, 531, 531, 532, 532, 532, 532, 533,
1233 533, 533, 534, 534, 534, 535, 535, 535, 535, 536,
1234 536, 536, 537, 537, 537, 538, 538, 538, 538, 539,
1235 539, 539, 540, 540, 540, 541, 541, 541, 541, 542,
1236 542, 542, 543, 543, 543, 544, 544, 544, 544, 545,
1237 545, 545, 546, 546, 546, 547, 547, 547, 548, 548,
1238 548, 548, 549, 549, 549, 550, 550, 550, 551, 551,
1239 551, 551, 552, 552, 552, 553, 553, 553, 554, 554,
1240 554, 554, 555, 555, 555, 556, 556, 556, 557, 557,
1241 557, 557, 558, 558, 558, 559, 559, 559, 560, 560,
1242 560, 560, 561, 561, 561, 562, 562, 562, 563, 563,
1243 563, 563, 564, 564, 564, 565, 565, 565, 566, 566,
1244 566, 566, 567, 567, 567, 568, 568, 568, 569, 569,
1245 569, 569, 570, 570, 570, 571, 571, 571, 572, 572,
1246 572, 572, 573, 573, 573, 574, 574, 574, 575, 575,
1247 575, 575, 576, 576, 576, 577, 577, 577, 578, 578,
1248 578, 579, 579, 579, 579, 580, 580, 580, 581, 581,
1249 581, 582, 582, 582, 582, 583, 583, 583, 584, 584,
1250 584, 585, 585, 585, 585, 586, 586, 586, 587, 587,
1251 587, 588, 588, 588, 588, 589, 589, 589, 590, 590,
1252 590, 591, 591, 591, 591, 592, 592, 592, 593, 593,
1253 593, 594, 594, 594, 594, 595, 595, 595, 596, 596,
1254 596, 597, 597, 597, 597, 598, 598, 598, 599, 599,
1255 599, 600, 600, 600, 600, 601, 601, 601, 602, 602,
1256 602, 603, 603, 603, 603, 604, 604, 604, 605, 605,
1257 605, 606, 606, 606, 607, 607, 607, 607, 608, 608,
1258 608, 609, 609, 609, 610, 610, 610, 610, 611, 611,
1259 611, 612, 612, 612, 613, 613, 613, 613, 614, 614,
1260 614, 615, 615, 615, 616, 616, 616, 616, 617, 617,
1261 617, 618, 618, 618, 619, 619, 619, 619, 620, 620,
1262 620, 621, 621, 621, 622, 622, 622, 622, 623, 623,
1263 623, 624, 624, 624, 625, 625, 625, 625, 626, 626,
1264 626, 627, 627, 627, 628, 628, 628, 628, 629, 629,
1265 629, 630, 630, 630, 631, 631, 631, 631, 632, 632,
1266 632, 633, 633, 633, 634, 634, 634, 634, 635, 635,
1267 635, 636, 636, 636, 637, 637, 637, 638, 638, 638,
1268 638, 639, 639, 639, 640, 640, 640, 641, 641, 641,
1269 641, 642, 642, 642, 643, 643, 643, 644, 644, 644,
1270 644, 645, 645, 645, 646, 646, 646, 647, 647, 647,
1271 647, 648, 648, 648, 649, 649, 649, 650, 650 };
1272 static ULLong pfive
[27] = {
1295 11920928955078125ll,
1296 59604644775390625ll,
1297 298023223876953125ll,
1298 1490116119384765625ll,
1299 7450580596923828125ll
1302 static int pfivebits
[25] = {3, 5, 7, 10, 12, 14, 17, 19, 21, 24, 26, 28, 31,
1303 33, 35, 38, 40, 42, 45, 47, 49, 52, 54, 56, 59};
1305 #endif /*}} NO_LONG_LONG */
1307 typedef union { double d
; ULong L
[2];
1314 #define word0(x) (x)->L[1]
1315 #define word1(x) (x)->L[0]
1317 #define word0(x) (x)->L[0]
1318 #define word1(x) (x)->L[1]
1320 #define dval(x) (x)->d
1321 #define LLval(x) (x)->LL
1323 #ifndef STRTOD_DIGLIM
1324 #define STRTOD_DIGLIM 40
1328 extern int strtod_diglim
;
1330 #define strtod_diglim STRTOD_DIGLIM
1333 /* The following definition of Storeinc is appropriate for MIPS processors.
1334 * An alternative that might be better on some machines is
1335 * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff)
1337 #if defined(IEEE_8087) + defined(VAX)
1338 #define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \
1339 ((unsigned short *)a)[0] = (unsigned short)c, a++)
1341 #define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \
1342 ((unsigned short *)a)[1] = (unsigned short)c, a++)
1345 /* #define P DBL_MANT_DIG */
1346 /* Ten_pmax = floor(P*log(2)/log(5)) */
1347 /* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
1348 /* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
1349 /* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
1352 #define Exp_shift 20
1353 #define Exp_shift1 20
1354 #define Exp_msk1 0x100000
1355 #define Exp_msk11 0x100000
1356 #define Exp_mask 0x7ff00000
1361 #define Emin (-1022)
1362 #define Exp_1 0x3ff00000
1363 #define Exp_11 0x3ff00000
1365 #define Frac_mask 0xfffff
1366 #define Frac_mask1 0xfffff
1369 #define Bndry_mask 0xfffff
1370 #define Bndry_mask1 0xfffff
1372 #define Sign_bit 0x80000000
1376 #define Quick_max 14
1378 #ifndef NO_IEEE_Scale
1379 #define Avoid_Underflow
1380 #ifdef Flush_Denorm /* debugging option */
1381 #undef Sudden_Underflow
1387 #define Flt_Rounds FLT_ROUNDS
1389 #define Flt_Rounds 1
1391 #endif /*Flt_Rounds*/
1393 #ifdef Honor_FLT_ROUNDS
1394 #undef Check_FLT_ROUNDS
1395 #define Check_FLT_ROUNDS
1397 #define Rounding Flt_Rounds
1400 #else /* ifndef IEEE_Arith */
1401 #undef Check_FLT_ROUNDS
1402 #undef Honor_FLT_ROUNDS
1404 #undef Sudden_Underflow
1405 #define Sudden_Underflow
1408 #define Flt_Rounds 0
1409 #define Exp_shift 24
1410 #define Exp_shift1 24
1411 #define Exp_msk1 0x1000000
1412 #define Exp_msk11 0x1000000
1413 #define Exp_mask 0x7f000000
1419 #define Exp_1 0x41000000
1420 #define Exp_11 0x41000000
1421 #define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
1422 #define Frac_mask 0xffffff
1423 #define Frac_mask1 0xffffff
1426 #define Bndry_mask 0xefffff
1427 #define Bndry_mask1 0xffffff
1429 #define Sign_bit 0x80000000
1431 #define Tiny0 0x100000
1433 #define Quick_max 14
1437 #define Flt_Rounds 1
1438 #define Exp_shift 23
1439 #define Exp_shift1 7
1440 #define Exp_msk1 0x80
1441 #define Exp_msk11 0x800000
1442 #define Exp_mask 0x7f80
1448 #define Exp_1 0x40800000
1449 #define Exp_11 0x4080
1451 #define Frac_mask 0x7fffff
1452 #define Frac_mask1 0xffff007f
1455 #define Bndry_mask 0xffff007f
1456 #define Bndry_mask1 0xffff007f
1458 #define Sign_bit 0x8000
1462 #define Quick_max 15
1464 #endif /* IBM, VAX */
1465 #endif /* IEEE_Arith */
1468 #define ROUND_BIASED
1470 #ifdef ROUND_BIASED_without_Round_Up
1472 #define ROUND_BIASED
1477 #define rounded_product(a,b) a = rnd_prod(a, b)
1478 #define rounded_quotient(a,b) a = rnd_quot(a, b)
1479 extern double rnd_prod(double, double), rnd_quot(double, double);
1481 #define rounded_product(a,b) a *= b
1482 #define rounded_quotient(a,b) a /= b
1485 #define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
1486 #define Big1 0xffffffff
1492 typedef struct BCinfo BCinfo
;
1494 BCinfo
{ int dp0
, dp1
, dplen
, dsign
, e0
, inexact
, nd
, nd0
, rounding
, scale
, uflchk
; };
1496 #define FFFFFFFF 0xffffffffUL
1498 #ifdef MULTIPLE_THREADS
1501 #define MTd , ThInfo **PTI
1502 static unsigned int maxthreads
= 0;
1504 #define MTa /*nothing*/
1505 #define MTb /*nothing*/
1506 #define MTd /*nothing*/
1512 extern "C" char *dtoa(double d
, int mode
, int ndigits
,
1513 int *decpt
, int *sign
, char **rve
);
1518 struct Bigint
*next
;
1519 int k
, maxwds
, sign
, wds
;
1523 typedef struct Bigint Bigint
;
1526 Bigint
*Freelist
[Kmax
+1];
1532 #ifdef MULTIPLE_THREADS
1534 static int TI0_used
;
1537 set_max_dtoa_threads(unsigned int n
)
1541 if (n
> maxthreads
) {
1542 L
= n
*sizeof(ThInfo
);
1544 TI1
= (ThInfo
*)REALLOC(TI1
, L
);
1545 memset(TI1
+ maxthreads
, 0, (n
-maxthreads
)*sizeof(ThInfo
));
1548 TI1
= (ThInfo
*)MALLOC(L
);
1550 memcpy(TI1
, &TI0
, sizeof(ThInfo
));
1552 memset(TI1
+ 1, 0, L
- sizeof(ThInfo
));
1553 memset(&TI0
, 0, sizeof(ThInfo
));
1565 unsigned int thno
= dtoa_get_threadno();
1566 if (thno
< maxthreads
)
1572 #define freelist TI->Freelist
1575 #define freelist TI0.Freelist
1584 #ifndef Omit_Private_Memory
1587 #ifdef MULTIPLE_THREADS
1591 *PTI
= TI
= get_TI();
1593 ACQUIRE_DTOA_LOCK(0);
1595 /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */
1596 /* but this case seems very unlikely. */
1597 if (k
<= Kmax
&& (rv
= freelist
[k
]))
1598 freelist
[k
] = rv
->next
;
1601 #ifdef Omit_Private_Memory
1602 rv
= (Bigint
*)MALLOC(sizeof(Bigint
) + (x
-1)*sizeof(ULong
));
1604 len
= (sizeof(Bigint
) + (x
-1)*sizeof(ULong
) + sizeof(double) - 1)
1606 if (k
<= Kmax
&& pmem_next
- private_mem
+ len
<= (ssize_t
)PRIVATE_mem
1607 #ifdef MULTIPLE_THREADS
1611 rv
= (Bigint
*)pmem_next
;
1615 rv
= (Bigint
*)MALLOC(len
*sizeof(double));
1620 #ifdef MULTIPLE_THREADS
1624 rv
->sign
= rv
->wds
= 0;
1629 Bfree(Bigint
*v MTd
)
1631 #ifdef MULTIPLE_THREADS
1638 #ifdef MULTIPLE_THREADS
1640 *PTI
= TI
= get_TI();
1642 ACQUIRE_DTOA_LOCK(0);
1644 v
->next
= freelist
[v
->k
];
1646 #ifdef MULTIPLE_THREADS
1654 #define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \
1655 y->wds*sizeof(Long) + 2*sizeof(int))
1658 multadd(Bigint
*b
, int m
, int a MTd
) /* multiply by m and add a */
1678 y
= *x
* (ULLong
)m
+ carry
;
1680 *x
++ = y
& FFFFFFFF
;
1684 y
= (xi
& 0xffff) * m
+ carry
;
1685 z
= (xi
>> 16) * m
+ (y
>> 16);
1687 *x
++ = (z
<< 16) + (y
& 0xffff);
1697 if (wds
>= b
->maxwds
) {
1698 b1
= Balloc(b
->k
+1 MTa
);
1703 b
->x
[wds
++] = (ULong
)carry
;
1714 if (!(x
& 0xffff0000)) {
1718 if (!(x
& 0xff000000)) {
1722 if (!(x
& 0xf0000000)) {
1726 if (!(x
& 0xc0000000)) {
1730 if (!(x
& 0x80000000)) {
1732 if (!(x
& 0x40000000))
1755 if (!(x
& 0xffff)) {
1793 mult(Bigint
*a
, Bigint
*b MTd
)
1797 ULong
*x
, *xa
, *xae
, *xb
, *xbe
, *xc
, *xc0
;
1808 if (a
->wds
< b
->wds
) {
1820 for(x
= c
->x
, xa
= x
+ wc
; x
< xa
; x
++)
1828 for(; xb
< xbe
; xc0
++) {
1834 z
= *x
++ * (ULLong
)y
+ *xc
+ carry
;
1836 *xc
++ = z
& FFFFFFFF
;
1844 for(; xb
< xbe
; xb
++, xc0
++) {
1845 if ((y
= *xb
& 0xffff)) {
1850 z
= (*x
& 0xffff) * y
+ (*xc
& 0xffff) + carry
;
1852 z2
= (*x
++ >> 16) * y
+ (*xc
>> 16) + carry
;
1854 Storeinc(xc
, z2
, z
);
1859 if ((y
= *xb
>> 16)) {
1865 z
= (*x
& 0xffff) * y
+ (*xc
>> 16) + carry
;
1867 Storeinc(xc
, z
, z2
);
1868 z2
= (*x
++ >> 16) * y
+ (*xc
& 0xffff) + carry
;
1876 for(; xb
< xbe
; xc0
++) {
1882 z
= *x
++ * y
+ *xc
+ carry
;
1892 for(xc0
= c
->x
, xc
= xc0
+ wc
; wc
> 0 && !*--xc
; --wc
) ;
1898 pow5mult(Bigint
*b
, int k MTd
)
1900 Bigint
*b1
, *p5
, *p51
;
1901 #ifdef MULTIPLE_THREADS
1905 static int p05
[3] = { 5, 25, 125 };
1908 b
= multadd(b
, p05
[i
-1], 0 MTa
);
1912 #ifdef MULTIPLE_THREADS
1914 *PTI
= TI
= get_TI();
1918 #ifdef MULTIPLE_THREADS
1920 *PTI
= TI
= get_TI();
1922 ACQUIRE_DTOA_LOCK(1);
1924 p5
= p5s
= i2b(625 MTa
);
1930 p5
= p5s
= i2b(625 MTa
);
1936 b1
= mult(b
, p5 MTa
);
1942 if (!(p51
= p5
->next
)) {
1943 #ifdef MULTIPLE_THREADS
1944 if (!TI
&& !(TI
= *PTI
))
1945 *PTI
= TI
= get_TI();
1947 ACQUIRE_DTOA_LOCK(1);
1948 if (!(p51
= p5
->next
)) {
1949 p51
= p5
->next
= mult(p5
,p5 MTa
);
1955 p51
= p5
->next
= mult(p5
,p5
);
1965 lshift(Bigint
*b
, int k MTd
)
1969 ULong
*x
, *x1
, *xe
, z
;
1977 n1
= n
+ b
->wds
+ 1;
1978 for(i
= b
->maxwds
; n1
> i
; i
<<= 1)
1980 b1
= Balloc(k1 MTa
);
1982 for(i
= 0; i
< n
; i
++)
1991 *x1
++ = *x
<< k
| z
;
2003 *x1
++ = *x
<< k
& 0xffff | z
;
2020 cmp(Bigint
*a
, Bigint
*b
)
2022 ULong
*xa
, *xa0
, *xb
, *xb0
;
2028 if (i
> 1 && !a
->x
[i
-1])
2029 Bug("cmp called with a->x[a->wds-1] == 0");
2030 if (j
> 1 && !b
->x
[j
-1])
2031 Bug("cmp called with b->x[b->wds-1] == 0");
2041 return *xa
< *xb
? -1 : 1;
2049 diff(Bigint
*a
, Bigint
*b MTd
)
2053 ULong
*xa
, *xae
, *xb
, *xbe
, *xc
;
2078 c
= Balloc(a
->k MTa
);
2090 y
= (ULLong
)*xa
++ - *xb
++ - borrow
;
2091 borrow
= y
>> 32 & (ULong
)1;
2092 *xc
++ = y
& FFFFFFFF
;
2097 borrow
= y
>> 32 & (ULong
)1;
2098 *xc
++ = y
& FFFFFFFF
;
2103 y
= (*xa
& 0xffff) - (*xb
& 0xffff) - borrow
;
2104 borrow
= (y
& 0x10000) >> 16;
2105 z
= (*xa
++ >> 16) - (*xb
++ >> 16) - borrow
;
2106 borrow
= (z
& 0x10000) >> 16;
2111 y
= (*xa
& 0xffff) - borrow
;
2112 borrow
= (y
& 0x10000) >> 16;
2113 z
= (*xa
++ >> 16) - borrow
;
2114 borrow
= (z
& 0x10000) >> 16;
2119 y
= *xa
++ - *xb
++ - borrow
;
2120 borrow
= (y
& 0x10000) >> 16;
2126 borrow
= (y
& 0x10000) >> 16;
2138 d2b(U
*d
, int *e
, int *bits MTd
)
2143 #ifndef Sudden_Underflow
2148 d0
= word0(d
) >> 16 | word0(d
) << 16;
2149 d1
= word1(d
) >> 16 | word1(d
) << 16;
2163 d0
&= 0x7fffffff; /* clear sign bit, which we ignore */
2164 #ifdef Sudden_Underflow
2165 de
= (int)(d0
>> Exp_shift
);
2170 if ((de
= (int)(d0
>> Exp_shift
)))
2175 if ((k
= lo0bits(&y
))) {
2176 x
[0] = y
| z
<< (32 - k
);
2181 #ifndef Sudden_Underflow
2184 b
->wds
= (x
[1] = z
) ? 2 : 1;
2189 #ifndef Sudden_Underflow
2197 if (k
= lo0bits(&y
))
2199 x
[0] = y
| z
<< 32 - k
& 0xffff;
2200 x
[1] = z
>> k
- 16 & 0xffff;
2206 x
[1] = y
>> 16 | z
<< 16 - k
& 0xffff;
2207 x
[2] = z
>> k
& 0xffff;
2222 Bug("Zero passed to d2b");
2240 #ifndef Sudden_Underflow
2244 *e
= (de
- Bias
- (P
-1) << 2) + k
;
2245 *bits
= 4*P
+ 8 - k
- hi0bits(word0(d
) & Frac_mask
);
2247 *e
= de
- Bias
- (P
-1) + k
;
2250 #ifndef Sudden_Underflow
2253 *e
= de
- Bias
- (P
-1) + 1 + k
;
2255 *bits
= 32*i
- hi0bits(x
[i
-1]);
2257 *bits
= (i
+2)*16 - hi0bits(x
[i
]);
2282 #define NAN_WORD0 0x7ff80000
2289 #endif /* INFNAN_CHECK */
2301 #if !defined(NO_HEX_FP) || defined(Honor_FLT_ROUNDS) /*{*/
2303 increment(Bigint
*b MTd
)
2311 if (*x
< (ULong
)0xffffffffL
) {
2318 if (b
->wds
>= b
->maxwds
) {
2319 b1
= Balloc(b
->k
+1 MTa
);
2332 dshift(Bigint
*b
, int p2
)
2334 int rv
= hi0bits(b
->x
[b
->wds
-1]) - 4;
2341 quorem(Bigint
*b
, Bigint
*S
)
2344 ULong
*bx
, *bxe
, q
, *sx
, *sxe
;
2346 ULLong borrow
, carry
, y
, ys
;
2348 ULong borrow
, carry
, y
, ys
;
2356 /*debug*/ if (b
->wds
> n
)
2357 /*debug*/ Bug("oversize b in quorem");
2365 q
= *bxe
/ (*sxe
+ 1); /* ensure q <= true quotient */
2367 #ifdef NO_STRTOD_BIGCOMP
2368 /*debug*/ if (q
> 9)
2370 /* An oversized q is possible when quorem is called from bigcomp and */
2371 /* the input is near, e.g., twice the smallest denormalized number. */
2372 /*debug*/ if (q
> 15)
2374 /*debug*/ Bug("oversized quotient in quorem");
2381 ys
= *sx
++ * (ULLong
)q
+ carry
;
2383 y
= *bx
- (ys
& FFFFFFFF
) - borrow
;
2384 borrow
= y
>> 32 & (ULong
)1;
2385 *bx
++ = y
& FFFFFFFF
;
2389 ys
= (si
& 0xffff) * q
+ carry
;
2390 zs
= (si
>> 16) * q
+ (ys
>> 16);
2392 y
= (*bx
& 0xffff) - (ys
& 0xffff) - borrow
;
2393 borrow
= (y
& 0x10000) >> 16;
2394 z
= (*bx
>> 16) - (zs
& 0xffff) - borrow
;
2395 borrow
= (z
& 0x10000) >> 16;
2398 ys
= *sx
++ * q
+ carry
;
2400 y
= *bx
- (ys
& 0xffff) - borrow
;
2401 borrow
= (y
& 0x10000) >> 16;
2409 while(--bxe
> bx
&& !*bxe
)
2414 if (cmp(b
, S
) >= 0) {
2424 y
= *bx
- (ys
& FFFFFFFF
) - borrow
;
2425 borrow
= y
>> 32 & (ULong
)1;
2426 *bx
++ = y
& FFFFFFFF
;
2430 ys
= (si
& 0xffff) + carry
;
2431 zs
= (si
>> 16) + (ys
>> 16);
2433 y
= (*bx
& 0xffff) - (ys
& 0xffff) - borrow
;
2434 borrow
= (y
& 0x10000) >> 16;
2435 z
= (*bx
>> 16) - (zs
& 0xffff) - borrow
;
2436 borrow
= (z
& 0x10000) >> 16;
2441 y
= *bx
- (ys
& 0xffff) - borrow
;
2442 borrow
= (y
& 0x10000) >> 16;
2451 while(--bxe
> bx
&& !*bxe
)
2459 #ifndef MULTIPLE_THREADS
2460 static char *dtoa_result
;
2464 rv_alloc(size_t i MTd
)
2470 sizeof(Bigint
) - sizeof(ULong
) - sizeof(int) + j
<= i
;
2473 r
= (int*)Balloc(k MTa
);
2476 #ifndef MULTIPLE_THREADS
2483 nrv_alloc(const char *s
, char *s0
, size_t s0len
, char **rve
, size_t n MTd
)
2488 s0
= rv_alloc(n MTa
);
2489 else if (s0len
<= n
) {
2503 /* freedtoa(s) must be used to free values s returned by dtoa
2504 * when MULTIPLE_THREADS is #defined. It should be used in all cases,
2505 * but for consistency with earlier versions of dtoa, it is optional
2506 * when MULTIPLE_THREADS is not defined.
2512 #ifdef MULTIPLE_THREADS
2515 Bigint
*b
= (Bigint
*)((int *)s
- 1);
2516 b
->maxwds
= 1 << (b
->k
= *(int*)b
);
2518 #ifndef MULTIPLE_THREADS
2519 if (s
== dtoa_result
)
2524 /* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
2526 * Inspired by "How to Print Floating-Point Numbers Accurately" by
2527 * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126].
2530 * 1. Rather than iterating, we use a simple numeric overestimate
2531 * to determine k = floor(log10(d)). We scale relevant
2532 * quantities using O(log2(k)) rather than O(k) multiplications.
2533 * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
2534 * try to generate digits strictly left to right. Instead, we
2535 * compute with fewer bits and propagate the carry if necessary
2536 * when rounding the final digit up. This is often faster.
2537 * 3. Under the assumption that input will be rounded nearest,
2538 * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
2539 * That is, we allow equality in stopping tests when the
2540 * round-nearest rule will give the same floating-point value
2541 * as would satisfaction of the stopping test with strict
2543 * 4. We remove common factors of powers of 2 from relevant
2545 * 5. When converting floating-point integers less than 1e16,
2546 * we use floating-point arithmetic rather than resorting
2547 * to multiple-precision integers.
2548 * 6. When asked to produce fewer than 15 digits, we first try
2549 * to get by with floating-point arithmetic; we resort to
2550 * multiple-precision integer arithmetic only if we cannot
2551 * guarantee that the floating-point calculation has given
2552 * the correctly rounded result. For k requested digits and
2553 * "uniformly" distributed input, the probability is
2554 * something like 10^(k-15) that we must resort to the Long
2559 dtoa_r(double dd
, int mode
, int ndigits
, int *decpt
, int *sign
, char **rve
, char *buf
, size_t blen
)
2561 /* Arguments ndigits, decpt, sign are similar to those
2562 of ecvt and fcvt; trailing zeros are suppressed from
2563 the returned string. If not null, *rve is set to point
2564 to the end of the return value. If d is +-Infinity or NaN,
2565 then *decpt is set to 9999.
2568 0 ==> shortest string that yields d when read in
2569 and rounded to nearest.
2570 1 ==> like 0, but with Steele & White stopping rule;
2571 e.g. with IEEE P754 arithmetic , mode 0 gives
2572 1e23 whereas mode 1 gives 9.999999999999999e22.
2573 2 ==> max(1,ndigits) significant digits. This gives a
2574 return value similar to that of ecvt, except
2575 that trailing zeros are suppressed.
2576 3 ==> through ndigits past the decimal point. This
2577 gives a return value similar to that from fcvt,
2578 except that trailing zeros are suppressed, and
2579 ndigits can be negative.
2580 4,5 ==> similar to 2 and 3, respectively, but (in
2581 round-nearest mode) with the tests of mode 0 to
2582 possibly return a shorter string that rounds to d.
2583 With IEEE arithmetic and compilation with
2584 -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same
2585 as modes 2 and 3 when FLT_ROUNDS != 1.
2586 6-9 ==> Debugging modes similar to mode - 4: don't try
2587 fast floating-point estimate (if applicable).
2589 Values of mode other than 0-9 are treated as mode 0.
2591 When not NULL, buf is an output buffer of length blen, which must
2592 be large enough to accommodate suppressed trailing zeros and a trailing
2593 null byte. If blen is too small, rv = NULL is returned, in which case
2594 if rve is not NULL, a subsequent call with blen >= (*rve - rv) + 1
2595 should succeed in returning buf.
2597 When buf is NULL, sufficient space is allocated for the return value,
2598 which, when done using, the caller should pass to freedtoa().
2600 USE_BF is automatically defined when neither NO_LONG_LONG nor NO_BF96
2604 #ifdef MULTIPLE_THREADS
2607 int bbits
, b2
, b5
, be
, dig
, i
, ilim
, ilim1
,
2608 j
, j1
, k
, leftright
, m2
, m5
, s2
, s5
, spec_case
;
2609 #if !defined(Sudden_Underflow) || defined(USE_BF96)
2612 Bigint
*b
, *b1
, *delta
, *mlo
, *mhi
, *S
;
2616 int inexact
, oldinexact
;
2618 #ifdef USE_BF96 /*{{*/
2620 ULLong dbhi
, dbits
, dblo
, den
, hb
, rb
, rblo
, res
, res0
, res3
, reslo
, sres
,
2621 sulp
, tv0
, tv1
, tv2
, tv3
, ulp
, ulplo
, ulpmask
, ures
, ureslo
, zb
;
2622 int eulp
, k1
, n2
, ulpadj
, ulpshift
;
2624 #ifndef Sudden_Underflow
2630 int ieps
, ilim0
, k0
, k_check
, try_quick
;
2631 #ifndef No_leftright
2637 #ifdef Honor_FLT_ROUNDS /*{*/
2639 #ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */
2640 Rounding
= Flt_Rounds
;
2643 switch(fegetround()) {
2644 case FE_TOWARDZERO
: Rounding
= 0; break;
2645 case FE_UPWARD
: Rounding
= 2; break;
2646 case FE_DOWNWARD
: Rounding
= 3;
2652 if (word0(&u
) & Sign_bit
) {
2653 /* set sign for everything, including 0's and NaNs */
2655 word0(&u
) &= ~Sign_bit
; /* clear sign bit */
2660 #if defined(IEEE_Arith) + defined(VAX)
2662 if ((word0(&u
) & Exp_mask
) == Exp_mask
)
2664 if (word0(&u
) == 0x8000)
2667 /* Infinity or NaN */
2670 if (!word1(&u
) && !(word0(&u
) & 0xfffff))
2671 return nrv_alloc("Infinity", buf
, blen
, rve
, 8 MTb
);
2673 return nrv_alloc("NaN", buf
, blen
, rve
, 3 MTb
);
2677 dval(&u
) += 0; /* normalize */
2681 return nrv_alloc("0", buf
, blen
, rve
, 1 MTb
);
2688 oldinexact
= get_inexact();
2691 #ifdef Honor_FLT_ROUNDS
2692 if (Rounding
>= 2) {
2694 Rounding
= Rounding
== 2 ? 0 : 2;
2700 #ifdef USE_BF96 /*{{*/
2701 dbits
= (u
.LL
& 0xfffffffffffffull
) << 11; /* fraction bits */
2702 if ((be
= u
.LL
>> 52)) /* biased exponent; nonzero ==> normal */ {
2703 dbits
|= 0x8000000000000000ull
;
2704 denorm
= ulpadj
= 0;
2710 if (!(dbits
& 0xffffffff00000000ull
)) {
2714 if (!(dbits
& 0xffff000000000000ull
)) {
2718 if (!(dbits
& 0xff00000000000000ull
)) {
2722 if (!(dbits
& 0xf000000000000000ull
)) {
2726 if (!(dbits
& 0xc000000000000000ull
)) {
2730 if (!(dbits
& 0x8000000000000000ull
)) {
2740 dblo
= dbits
& 0xffffffffull
;
2743 || (i
== p10
->e
&& (dbhi
< p10
->b0
|| (dbhi
== p10
->b0
&& dblo
< p10
->b1
))))
2747 /* now 10^k <= dd < 10^(k+1) */
2751 b
= d2b(&u
, &be
, &bbits MTb
);
2752 #ifdef Sudden_Underflow
2753 i
= (int)(word0(&u
) >> Exp_shift1
& (Exp_mask
>>Exp_shift1
));
2755 if ((i
= (int)(word0(&u
) >> Exp_shift1
& (Exp_mask
>>Exp_shift1
)))) {
2757 dval(&d2
) = dval(&u
);
2758 word0(&d2
) &= Frac_mask1
;
2759 word0(&d2
) |= Exp_11
;
2761 if (j
= 11 - hi0bits(word0(&d2
) & Frac_mask
))
2762 dval(&d2
) /= 1 << j
;
2765 /* log(x) ~=~ log(1.5) + (x-1.5)/1.5
2766 * log10(x) = log(x) / log(10)
2767 * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
2768 * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)
2770 * This suggests computing an approximation k to log10(d) by
2772 * k = (i - Bias)*0.301029995663981
2773 * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
2775 * We want k to be too large rather than too small.
2776 * The error in the first-order Taylor series approximation
2777 * is in our favor, so we just round up the constant enough
2778 * to compensate for any error in the multiplication of
2779 * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,
2780 * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
2781 * adding 1e-13 to the constant term more than suffices.
2782 * Hence we adjust the constant term to 0.1760912590558.
2783 * (We could get a more accurate k by invoking log10,
2784 * but this is probably not worthwhile.)
2792 #ifndef Sudden_Underflow
2796 /* d is denormalized */
2798 i
= bbits
+ be
+ (Bias
+ (P
-1) - 1);
2799 x
= i
> 32 ? word0(&u
) << (64 - i
) | word1(&u
) >> (i
- 32)
2800 : word1(&u
) << (32 - i
);
2802 word0(&d2
) -= 31*Exp_msk1
; /* adjust exponent */
2803 i
-= (Bias
+ (P
-1) - 1) + 1;
2807 ds
= (dval(&d2
)-1.5)*0.289529654602168 + 0.1760912590558 + i
*0.301029995663981;
2809 if (ds
< 0. && ds
!= k
)
2810 k
--; /* want k = floor(ds) */
2812 if (k
>= 0 && k
<= Ten_pmax
) {
2813 if (dval(&u
) < tens
[k
])
2837 if (mode
< 0 || mode
> 9)
2842 #ifdef Check_FLT_ROUNDS
2843 try_quick
= Rounding
== 1;
2847 #endif /*SET_INEXACT*/
2857 ilim
= ilim1
= -1; /* Values for cases 0 and 1; done here to */
2858 /* silence erroneous "gcc -Wall" warning. */
2871 ilim
= ilim1
= i
= ndigits
;
2877 i
= ndigits
+ k
+ 1;
2884 buf
= rv_alloc(i MTb
);
2885 blen
= sizeof(Bigint
) + ((1 << ((int*)buf
)[-1]) - 1)*sizeof(ULong
) - sizeof(int);
2887 else if (blen
<= (size_t)i
) {
2895 /* Check for special case that d is a normalized power of 2. */
2898 if (mode
< 2 || (leftright
2899 #ifdef Honor_FLT_ROUNDS
2903 if (!word1(&u
) && !(word0(&u
) & Bndry_mask
)
2904 #ifndef Sudden_Underflow
2905 && word0(&u
) & (Exp_mask
& ~Exp_msk1
)
2908 /* The special case */
2913 #ifdef USE_BF96 /*{*/
2915 if (ilim
< 0 && (mode
== 3 || mode
== 5)) {
2920 j
= 52 + 0x3ff - be
;
2923 /* Can we do an exact computation with 64-bit integer arithmetic? */
2928 n2
= pfivebits
[k1
= -(k
+ 1)] + 53;
2932 if (res
& (ulpmask
= (1ull << ulpshift
) - 1))
2938 res
*= ulp
= pfive
[k1
];
2946 if (res
> (5ull << j
))
2952 if (ilim
== 0 && j
+ k
>= 0) {
2954 if ((dbits
>> 11) > (pfive
[k
-1] << j
))
2958 if (k
<= dtoa_divmax
&& j
+ k
>= 0) {
2959 /* Another "yes" case -- we will use exact integer arithmetic. */
2961 Debug(++dtoa_stats
[3]);
2962 res
= dbits
>> 11; /* residual */
2967 den
= pfive
[k
-i
] << (j1
- i
);
2969 dig
= (int)(res
/ den
);
2971 if (!(res
-= dig
*den
)) {
2981 && (spec_case
? 4*res
<= ulp
: (2*res
< ulp
|| dig
& 1)))
2986 else if (i
== ilim
) {
2989 case 2: goto Roundup
;
2993 || (ures
== den
&& dig
& 1)
2994 || (spec_case
&& res
<= ulp
&& 2*res
>= ulp
))
3005 den
= pfive
[k
-i
] << (j1
- i
);
3013 if (!(res
-= den
<< j
)) {
3021 ures
= (1ull << j
) - res
;
3023 && (spec_case
? 4*res
<= ulp
: (2*res
< ulp
|| dig
& 1))) {
3026 || (ures
== res
&& dig
& 1)
3027 || (dig
== 9 && 2*ures
<= ulp
))
3036 #ifdef Honor_FLT_ROUNDS
3039 case 2: goto Roundup
;
3043 if (res
& hb
&& (dig
& 1 || res
& (hb
-1)))
3045 if (spec_case
&& res
<= ulp
&& 2*res
>= ulp
) {
3061 ulplo
= 5*(ulplo
& ulpmask
);
3062 ulp
= 5*ulp
+ (ulplo
>> ulpshift
);
3071 /* Scale by 10^-k */
3073 tv0
= p10
->b2
* dblo
; /* rarely matters, but does, e.g., for 9.862818194192001e18 */
3074 tv1
= p10
->b1
* dblo
+ (tv0
>> 32);
3075 tv2
= p10
->b2
* dbhi
+ (tv1
& 0xffffffffull
);
3076 tv3
= p10
->b0
* dblo
+ (tv1
>>32) + (tv2
>>32);
3077 res3
= p10
->b1
* dbhi
+ (tv3
& 0xffffffffull
);
3078 res
= p10
->b0
* dbhi
+ (tv3
>>32) + (res3
>>32);
3079 be
+= p10
->e
- 0x3fe;
3080 eulp
= j1
= be
- 54 + ulpadj
;
3081 if (!(res
& 0x8000000000000000ull
)) {
3084 res
= (res
<< 1) | ((res3
& 0x100000000ull
) >> 32);
3086 res0
= res
; /* save for Fast_failed */
3087 #if !defined(SET_INEXACT) && !defined(NO_DTOA_64) /*{*/
3090 Debug(++dtoa_stats
[4]);
3091 assert(be
>= 0 && be
<= 4); /* be = 0 is rare, but possible, e.g., for 1e20 */
3093 ulp
= p10
->b0
; /* ulp */
3094 ulp
= (ulp
<< 29) | (p10
->b1
>> 3);
3095 /* scaled ulp = ulp * 2^(eulp - 60) */
3096 /* We maintain 61 bits of the scaled ulp. */
3098 if (!(res
& 0x7fffffffffffffeull
)
3099 || !((~res
) & 0x7fffffffffffffeull
))
3102 if (res
>= 0x5000000000000000ull
)
3106 rb
= 1; /* upper bound on rounding error */
3110 res
&= 0xfffffffffffffffull
;
3112 ures
= 0x1000000000000000ull
- res
;
3115 sulp
= ulp
<< (eulp
- 1);
3117 if (res
+ rb
> ures
- rb
)
3123 if (res
- rb
<= ures
+ rb
)
3130 zb
= -(1ull << (eulp
+ 63));
3132 sres
= res
<< (1 - eulp
);
3133 if (sres
< ulp
&& (!spec_case
|| 2*sres
< ulp
)) {
3134 if ((res
+rb
) << (1 - eulp
) >= ulp
)
3137 if (ures
+ rb
>= res
- rb
)
3141 if (ures
- rb
< res
+ rb
)
3146 if (!(zb
& ures
) && ures
<< -eulp
< ulp
) {
3147 if (ures
<< (1 - eulp
) < ulp
)
3153 else if (i
== ilim
) {
3154 ures
= 0x1000000000000000ull
- res
;
3156 if (ures
<= rb
|| res
- rb
<= ures
+ rb
) {
3157 if (j
+ k
>= 0 && k
>= 0 && k
<= 27)
3161 #ifdef Honor_FLT_ROUNDS
3167 if (res
<= rb
|| ures
- rb
<= res
+ rb
) {
3168 if (j
+ k
>= 0 && k
>= 0 && k
<= 27) {
3176 #ifdef Honor_FLT_ROUNDS
3183 if (rb
>= 0x1000000000000000ull
)
3187 if (ulp
& 0x8000000000000000ull
) {
3200 Debug(++dtoa_stats
[5]);
3204 reslo
= 0xffffffffull
& res3
;
3206 reslo
= (res0
<< (64 - i
)) >> 32 | (reslo
>> i
);
3208 rblo
= 4; /* roundoff bound */
3209 ulp
= p10
->b0
; /* ulp */
3210 ulp
= (ulp
<< 29) | (p10
->b1
>> 3);
3215 res
&= 0xfffffffffffffffull
;
3217 if (!res
&& !reslo
) {
3218 if (!(res3
& 0xffffffffull
)) {
3226 ures
= 0x1000000000000000ull
- res
;
3229 ureslo
= 0x100000000ull
- reslo
;
3234 sulp
= (ulp
<< (eulp
- 1)) - rb
;
3237 if (res
+rb
< ures
-rb
)
3241 else if (ures
< sulp
) {
3242 if (res
-rb
> ures
+rb
)
3248 zb
= -(1ull << (eulp
+ 60));
3249 if (!(zb
& (res
+ rb
))) {
3250 sres
= (res
- rb
) << (1 - eulp
);
3251 if (sres
< ulp
&& (!spec_case
|| 2*sres
< ulp
)) {
3252 sres
= res
<< (1 - eulp
);
3253 if ((j
= eulp
+ 31) > 0)
3254 sres
+= (rblo
+ reslo
) >> j
;
3256 sres
+= (rblo
+ reslo
) << -j
;
3257 if (sres
+ (rb
<< (1 - eulp
)) >= ulp
)
3262 || (ures
== res
&& ureslo
< reslo
)) {
3263 if (ures
+ rb
>= res
- rb
)
3267 if (ures
- rb
<= res
+ rb
)
3272 if (!(zb
& ures
) && (ures
-rb
) << (1 - eulp
) < ulp
) {
3273 if ((ures
+ rb
) << (2 - eulp
) < ulp
)
3279 else if (i
== ilim
) {
3280 ures
= 0x1000000000000000ull
- res
;
3283 ureslo
= 0x100000000ull
- reslo
;
3285 sres
= (reslo
+ rblo
) >> 31;
3289 if (ures
<=sres
|| res
- ures
<= sres
)
3291 #ifdef Honor_FLT_ROUNDS
3297 if (res
<= sres
|| ures
- res
<= sres
)
3299 #ifdef Honor_FLT_ROUNDS
3307 rb
= 10*rb
+ (rblo
>> 32);
3308 rblo
&= 0xffffffffull
;
3309 if (rb
>= 0x1000000000000000ull
)
3312 res
= 10*res
+ (reslo
>> 32);
3313 reslo
&= 0xffffffffull
;
3315 if (ulp
& 0x8000000000000000ull
) {
3325 Debug(++dtoa_stats
[6]);
3328 b
= d2b(&u
, &be
, &bbits MTb
);
3331 i
= (int)(word0(&u
) >> Exp_shift1
& (Exp_mask
>>Exp_shift1
));
3356 #ifdef Honor_FLT_ROUNDS
3357 if (mode
> 1 && Rounding
!= 1)
3361 #ifndef USE_BF96 /*{*/
3362 if (ilim
>= 0 && ilim
<= Quick_max
&& try_quick
) {
3364 /* Try to get by with floating-point arithmetic. */
3367 dval(&d2
) = dval(&u
);
3370 ieps
= 2; /* conservative */
3375 /* prevent overflows */
3377 dval(&u
) /= bigtens
[n_bigtens
-1];
3380 for(; j
; j
>>= 1, i
++)
3388 dval(&u
) *= tens
[j1
& 0xf];
3389 for(j
= j1
>> 4; j
; j
>>= 1, i
++)
3392 dval(&u
) *= bigtens
[i
];
3395 if (k_check
&& dval(&u
) < 1. && ilim
> 0) {
3403 dval(&eps
) = ieps
*dval(&u
) + 7.;
3404 word0(&eps
) -= (P
-1)*Exp_msk1
;
3408 if (dval(&u
) > dval(&eps
))
3410 if (dval(&u
) < -dval(&eps
))
3414 #ifndef No_leftright
3416 /* Use Steele & White method of only
3417 * generating digits needed.
3419 dval(&eps
) = 0.5/tens
[ilim
-1] - dval(&eps
);
3422 eps1
.d
= 1.01e256
; /* 1.01 allows roundoff in the next few lines */
3423 word0(&eps1
) -= Exp_msk1
* (Bias
+P
-1);
3424 dval(&eps1
) *= tens
[j1
& 0xf];
3425 for(i
= 0, j
= (j1
-256) >> 4; j
; j
>>= 1, i
++)
3427 dval(&eps1
) *= bigtens
[i
];
3430 if (10. - u
.d
< 10.*eps
.d
&& eps
.d
< 1.) {
3431 /* eps.d < 1. excludes trouble with the tiniest denormal */
3441 *s
++ = '0' + (int)L
;
3442 if (1. - dval(&u
) < dval(&eps
))
3444 if (dval(&u
) < dval(&eps
))
3454 /* Generate ilim digits, then fix them up. */
3455 dval(&eps
) *= tens
[ilim
-1];
3456 for(i
= 1;; i
++, dval(&u
) *= 10.) {
3457 L
= (Long
)(dval(&u
));
3458 if (!(dval(&u
) -= L
))
3460 *s
++ = '0' + (int)L
;
3462 if (dval(&u
) > 0.5 + dval(&eps
))
3464 else if (dval(&u
) < 0.5 - dval(&eps
))
3469 #ifndef No_leftright
3474 dval(&u
) = dval(&d2
);
3479 /* Do we have a "small" integer? */
3481 if (be
>= 0 && k
<= Int_max
) {
3484 if (ndigits
< 0 && ilim
<= 0) {
3486 if (ilim
< 0 || dval(&u
) <= 5*ds
)
3490 for(i
= 1;; i
++, dval(&u
) *= 10.) {
3491 L
= (Long
)(dval(&u
) / ds
);
3493 #ifdef Check_FLT_ROUNDS
3494 /* If FLT_ROUNDS == 2, L will usually be high by 1 */
3500 *s
++ = '0' + (int)L
;
3508 #ifdef Honor_FLT_ROUNDS
3512 case 2: goto bump_up
;
3515 dval(&u
) += dval(&u
);
3519 if (dval(&u
) > ds
|| (dval(&u
) == ds
&& L
& 1))
3543 #ifndef Sudden_Underflow
3544 denorm
? be
+ (Bias
+ (P
-1) - 1 + 1) :
3547 1 + 4*P
- 3 - bbits
+ ((bbits
+ be
- 1) & 3);
3555 if (m2
> 0 && s2
> 0) {
3556 i
= m2
< s2
? m2
: s2
;
3564 mhi
= pow5mult(mhi
, m5 MTb
);
3565 b1
= mult(mhi
, b MTb
);
3570 b
= pow5mult(b
, j MTb
);
3573 b
= pow5mult(b
, b5 MTb
);
3577 S
= pow5mult(S
, s5 MTb
);
3584 /* Arrange for convenient computation of quotients:
3585 * shift left if necessary so divisor has 4 leading 0 bits.
3587 * Perhaps we should just compute leading 28 bits of S once
3588 * and for all and pass them and a shift to quorem, so it
3589 * can do shifts and ors to compute the numerator for q.
3596 b
= lshift(b
, b2 MTb
);
3598 S
= lshift(S
, s2 MTb
);
3603 b
= multadd(b
, 10, 0 MTb
); /* we botched the k estimate */
3605 mhi
= multadd(mhi
, 10, 0 MTb
);
3610 if (ilim
<= 0 && (mode
== 3 || mode
== 5)) {
3611 if (ilim
< 0 || cmp(b
,S
= multadd(S
,5,0 MTb
)) <= 0) {
3612 /* no digits, fcvt style */
3624 mhi
= lshift(mhi
, m2 MTb
);
3626 /* Compute mlo -- check for special case
3627 * that d is a normalized power of 2.
3632 mhi
= Balloc(mhi
->k MTb
);
3634 mhi
= lshift(mhi
, Log2P MTb
);
3638 dig
= quorem(b
,S
) + '0';
3639 /* Do we yet have the shortest decimal string
3640 * that will round to d?
3643 delta
= diff(S
, mhi MTb
);
3644 j1
= delta
->sign
? 1 : cmp(b
, delta
);
3646 #ifndef ROUND_BIASED
3647 if (j1
== 0 && mode
!= 1 && !(word1(&u
) & 1)
3648 #ifdef Honor_FLT_ROUNDS
3649 && (mode
<= 1 || Rounding
>= 1)
3657 else if (!b
->x
[0] && b
->wds
<= 1)
3664 if (j
< 0 || (j
== 0 && mode
!= 1
3665 #ifndef ROUND_BIASED
3669 if (!b
->x
[0] && b
->wds
<= 1) {
3675 #ifdef Honor_FLT_ROUNDS
3678 case 0: goto accept_dig
;
3679 case 2: goto keep_dig
;
3681 #endif /*Honor_FLT_ROUNDS*/
3683 b
= lshift(b
, 1 MTb
);
3688 if ((j1
> 0 || (j1
== 0 && dig
& 1))
3698 #ifdef Honor_FLT_ROUNDS
3699 if (!Rounding
&& mode
> 1)
3702 if (dig
== '9') { /* possible if i == 1 */
3710 #ifdef Honor_FLT_ROUNDS
3716 b
= multadd(b
, 10, 0 MTb
);
3718 mlo
= mhi
= multadd(mhi
, 10, 0 MTb
);
3720 mlo
= multadd(mlo
, 10, 0 MTb
);
3721 mhi
= multadd(mhi
, 10, 0 MTb
);
3727 dig
= quorem(b
,S
) + '0';
3729 if (!b
->x
[0] && b
->wds
<= 1) {
3737 b
= multadd(b
, 10, 0 MTb
);
3740 /* Round off last digit */
3742 #ifdef Honor_FLT_ROUNDS
3746 case 2: goto roundoff
;
3749 b
= lshift(b
, 1 MTb
);
3754 if (j
> 0 || (j
== 0 && dig
& 1))
3769 if (mlo
&& mlo
!= mhi
)
3774 while(s
> buf
&& s
[-1] == '0')
3786 word0(&u
) = Exp_1
+ (70 << Exp_shift
);
3791 else if (!oldinexact
)
3798 dtoa(double dd
, int mode
, int ndigits
, int *decpt
, int *sign
, char **rve
)
3800 /* Sufficient space is allocated to the return value
3801 to hold the suppressed trailing zeros.
3802 See dtoa_r() above for details on the other arguments.
3804 #ifndef MULTIPLE_THREADS
3806 freedtoa(dtoa_result
);
3808 return dtoa_r(dd
, mode
, ndigits
, decpt
, sign
, rve
, 0, 0);
3813 dtoa_g_fmt(register char *b
, double x
)
3821 #ifdef IGNORE_ZERO_SIGN
3828 s
= s0
= dtoa(x
, 0, 0, &decpt
, &sign
, &se
);
3831 if (decpt
== 9999) /* Infinity or Nan */ {
3832 while((*b
++ = *s
++));
3835 if (decpt
<= -4 || decpt
> se
- s
+ 5) {
3843 /* sprintf(b, "%+.2d", decpt - 1); */
3850 for(j
= 2, k
= 10; 10*k
<= decpt
; j
++, k
*= 10);
3861 else if (decpt
<= 0) {
3862 *b
++ = '0'; // Add leading zero, not in dmg's original
3864 for(; decpt
< 0; decpt
++)
3866 while((*b
++ = *s
++));
3869 while((*b
= *s
++)) {
3871 if (--decpt
== 0 && *s
)
3874 for(; decpt
> 0; decpt
--)
3880 #ifdef IGNORE_ZERO_SIGN