diff options
| -rw-r--r-- | .travis.yml | 10 | ||||
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | dtoa.c | 2863 | ||||
| -rw-r--r-- | dtoa_config.h | 6 | ||||
| -rw-r--r-- | fpconv.h | 12 | ||||
| -rwxr-xr-x | runtests.sh | 10 |
6 files changed, 2389 insertions, 514 deletions
diff --git a/.travis.yml b/.travis.yml index 91f73ff..091ff98 100644 --- a/.travis.yml +++ b/.travis.yml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | sudo: required | 1 | sudo: required |
| 2 | dist: trusty | 2 | dist: Focal |
| 3 | 3 | ||
| 4 | os: linux | 4 | os: linux |
| 5 | 5 | ||
| @@ -17,6 +17,7 @@ addons: | |||
| 17 | - libipc-run3-perl | 17 | - libipc-run3-perl |
| 18 | - lua5.1 | 18 | - lua5.1 |
| 19 | - lua5.1-dev | 19 | - lua5.1-dev |
| 20 | - cmake | ||
| 20 | 21 | ||
| 21 | cache: | 22 | cache: |
| 22 | apt: true | 23 | apt: true |
| @@ -30,6 +31,7 @@ env: | |||
| 30 | - LUAJIT=1 LUA_DIR=/usr/local LUA_INCLUDE_DIR=$LUA_DIR/include/luajit-2.1 LUA_SUFFIX=--lua-suffix=jit | 31 | - LUAJIT=1 LUA_DIR=/usr/local LUA_INCLUDE_DIR=$LUA_DIR/include/luajit-2.1 LUA_SUFFIX=--lua-suffix=jit |
| 31 | 32 | ||
| 32 | install: | 33 | install: |
| 34 | - sudo ln -s /usr/bin/cmake /usr/local/bin/cmake | ||
| 33 | - if [ -n "$LUAJIT" ]; then git clone -b v2.1-agentzh https://github.com/openresty/luajit2.git; fi | 35 | - if [ -n "$LUAJIT" ]; then git clone -b v2.1-agentzh https://github.com/openresty/luajit2.git; fi |
| 34 | - if [ -n "$LUAJIT" ]; then cd ./luajit2; fi | 36 | - if [ -n "$LUAJIT" ]; then cd ./luajit2; fi |
| 35 | - if [ -n "$LUAJIT" ]; then make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC XCFLAGS='-DLUA_USE_APICHECK -DLUA_USE_ASSERT' > build.log 2>&1 || (cat build.log && exit 1); fi | 37 | - if [ -n "$LUAJIT" ]; then make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC XCFLAGS='-DLUA_USE_APICHECK -DLUA_USE_ASSERT' > build.log 2>&1 || (cat build.log && exit 1); fi |
| @@ -53,3 +55,9 @@ script: | |||
| 53 | - TEST_LUA_USE_VALGRIND=1 prove -Itests tests > build.log 2>&1; export e=$? | 55 | - TEST_LUA_USE_VALGRIND=1 prove -Itests tests > build.log 2>&1; export e=$? |
| 54 | - cat build.log | 56 | - cat build.log |
| 55 | - grep -E '^==[0-9]+==' build.log; if [ "$?" == 0 ]; then exit 1; else exit $e; fi | 57 | - grep -E '^==[0-9]+==' build.log; if [ "$?" == 0 ]; then exit 1; else exit $e; fi |
| 58 | - cmake -DUSE_INTERNAL_FPCONV=1 . | ||
| 59 | - make | ||
| 60 | - prove -Itests tests | ||
| 61 | - TEST_LUA_USE_VALGRIND=1 prove -Itests tests > build.log 2>&1; export e=$? | ||
| 62 | - cat build.log | ||
| 63 | - grep -E '^==[0-9]+==' build.log; if [ "$?" == 0 ]; then exit 1; else exit $e; fi | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt index c1d670d..f7eaf89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | # Windows: set LUA_DIR=c:\lua51 | 4 | # Windows: set LUA_DIR=c:\lua51 |
| 5 | 5 | ||
| 6 | project(lua-cjson C) | 6 | project(lua-cjson C) |
| 7 | cmake_minimum_required(VERSION 2.6) | 7 | cmake_minimum_required(VERSION 2.8.12) |
| 8 | 8 | ||
| 9 | option(USE_INTERNAL_FPCONV "Use internal strtod() / g_fmt() code for performance") | 9 | option(USE_INTERNAL_FPCONV "Use internal strtod() / g_fmt() code for performance") |
| 10 | option(MULTIPLE_THREADS "Support multi-threaded apps with internal fpconv - recommended" ON) | 10 | option(MULTIPLE_THREADS "Support multi-threaded apps with internal fpconv - recommended" ON) |
| @@ -32,6 +32,7 @@ | |||
| 32 | */ | 32 | */ |
| 33 | 33 | ||
| 34 | /* strtod for IEEE-, VAX-, and IBM-arithmetic machines. | 34 | /* strtod for IEEE-, VAX-, and IBM-arithmetic machines. |
| 35 | * (Note that IEEE arithmetic is disabled by gcc's -ffast-math flag.) | ||
| 35 | * | 36 | * |
| 36 | * This strtod returns a nearest machine number to the input decimal | 37 | * This strtod returns a nearest machine number to the input decimal |
| 37 | * string (or sets errno to ERANGE). With IEEE arithmetic, ties are | 38 | * string (or sets errno to ERANGE). With IEEE arithmetic, ties are |
| @@ -102,7 +103,6 @@ | |||
| 102 | * something other than "long long", #define Llong to be the name, | 103 | * something other than "long long", #define Llong to be the name, |
| 103 | * and if "unsigned Llong" does not work as an unsigned version of | 104 | * and if "unsigned Llong" does not work as an unsigned version of |
| 104 | * Llong, #define #ULLong to be the corresponding unsigned type. | 105 | * Llong, #define #ULLong to be the corresponding unsigned type. |
| 105 | * #define KR_headers for old-style C function headers. | ||
| 106 | * #define Bad_float_h if your system lacks a float.h or if it does not | 106 | * #define Bad_float_h if your system lacks a float.h or if it does not |
| 107 | * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, | 107 | * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, |
| 108 | * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. | 108 | * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. |
| @@ -152,6 +152,25 @@ | |||
| 152 | * probability of wasting memory, but would otherwise be harmless.) | 152 | * probability of wasting memory, but would otherwise be harmless.) |
| 153 | * You must also invoke freedtoa(s) to free the value s returned by | 153 | * You must also invoke freedtoa(s) to free the value s returned by |
| 154 | * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined. | 154 | * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined. |
| 155 | |||
| 156 | * When MULTIPLE_THREADS is #defined, this source file provides | ||
| 157 | * void set_max_dtoa_threads(unsigned int n); | ||
| 158 | * and expects | ||
| 159 | * unsigned int dtoa_get_threadno(void); | ||
| 160 | * to be available (possibly provided by | ||
| 161 | * #define dtoa_get_threadno omp_get_thread_num | ||
| 162 | * if OpenMP is in use or by | ||
| 163 | * #define dtoa_get_threadno pthread_self | ||
| 164 | * if Pthreads is in use), to return the current thread number. | ||
| 165 | * If set_max_dtoa_threads(n) was called and the current thread | ||
| 166 | * number is k with k < n, then calls on ACQUIRE_DTOA_LOCK(...) and | ||
| 167 | * FREE_DTOA_LOCK(...) are avoided; instead each thread with thread | ||
| 168 | * number < n has a separate copy of relevant data structures. | ||
| 169 | * After set_max_dtoa_threads(n), a call set_max_dtoa_threads(m) | ||
| 170 | * with m <= n has has no effect, but a call with m > n is honored. | ||
| 171 | * Such a call invokes REALLOC (assumed to be "realloc" if REALLOC | ||
| 172 | * is not #defined) to extend the size of the relevant array. | ||
| 173 | |||
| 155 | * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that | 174 | * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that |
| 156 | * avoids underflows on inputs whose result does not underflow. | 175 | * avoids underflows on inputs whose result does not underflow. |
| 157 | * If you #define NO_IEEE_Scale on a machine that uses IEEE-format | 176 | * If you #define NO_IEEE_Scale on a machine that uses IEEE-format |
| @@ -175,6 +194,11 @@ | |||
| 175 | * inexact or when it is a numeric value rounded to +-infinity). | 194 | * inexact or when it is a numeric value rounded to +-infinity). |
| 176 | * #define NO_ERRNO if strtod should not assign errno = ERANGE when | 195 | * #define NO_ERRNO if strtod should not assign errno = ERANGE when |
| 177 | * the result overflows to +-Infinity or underflows to 0. | 196 | * the result overflows to +-Infinity or underflows to 0. |
| 197 | * When errno should be assigned, under seemingly rare conditions | ||
| 198 | * it may be necessary to define Set_errno(x) suitably, e.g., in | ||
| 199 | * a local errno.h, such as | ||
| 200 | * #include <errno.h> | ||
| 201 | * #define Set_errno(x) _set_errno(x) | ||
| 178 | * #define NO_HEX_FP to omit recognition of hexadecimal floating-point | 202 | * #define NO_HEX_FP to omit recognition of hexadecimal floating-point |
| 179 | * values by strtod. | 203 | * values by strtod. |
| 180 | * #define NO_STRTOD_BIGCOMP (on IEEE-arithmetic systems only for now) | 204 | * #define NO_STRTOD_BIGCOMP (on IEEE-arithmetic systems only for now) |
| @@ -188,15 +212,21 @@ | |||
| 188 | #include "dtoa_config.h" | 212 | #include "dtoa_config.h" |
| 189 | 213 | ||
| 190 | #ifndef Long | 214 | #ifndef Long |
| 191 | #define Long long | 215 | #define Long int |
| 192 | #endif | 216 | #endif |
| 193 | #ifndef ULong | 217 | #ifndef ULong |
| 194 | typedef unsigned Long ULong; | 218 | typedef unsigned Long ULong; |
| 195 | #endif | 219 | #endif |
| 196 | 220 | ||
| 197 | #ifdef DEBUG | 221 | #ifdef DEBUG |
| 222 | #include <assert.h> | ||
| 198 | #include "stdio.h" | 223 | #include "stdio.h" |
| 199 | #define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} | 224 | #define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} |
| 225 | #define Debug(x) x | ||
| 226 | int dtoa_stats[7]; /* strtod_{64,96,bigcomp},dtoa_{exact,64,96,bigcomp} */ | ||
| 227 | #else | ||
| 228 | #define assert(x) /*nothing*/ | ||
| 229 | #define Debug(x) /*nothing*/ | ||
| 200 | #endif | 230 | #endif |
| 201 | 231 | ||
| 202 | #include "stdlib.h" | 232 | #include "stdlib.h" |
| @@ -212,16 +242,29 @@ typedef unsigned Long ULong; | |||
| 212 | #endif | 242 | #endif |
| 213 | #endif | 243 | #endif |
| 214 | 244 | ||
| 245 | #ifdef __cplusplus | ||
| 246 | extern "C" { | ||
| 247 | #endif | ||
| 215 | #ifdef MALLOC | 248 | #ifdef MALLOC |
| 216 | #ifdef KR_headers | ||
| 217 | extern char *MALLOC(); | ||
| 218 | #else | ||
| 219 | extern void *MALLOC(size_t); | 249 | extern void *MALLOC(size_t); |
| 220 | #endif | ||
| 221 | #else | 250 | #else |
| 222 | #define MALLOC malloc | 251 | #define MALLOC malloc |
| 223 | #endif | 252 | #endif |
| 224 | 253 | ||
| 254 | #ifdef REALLOC | ||
| 255 | extern void *REALLOC(void*,size_t); | ||
| 256 | #else | ||
| 257 | #define REALLOC realloc | ||
| 258 | #endif | ||
| 259 | |||
| 260 | #ifndef FREE | ||
| 261 | #define FREE free | ||
| 262 | #endif | ||
| 263 | |||
| 264 | #ifdef __cplusplus | ||
| 265 | } | ||
| 266 | #endif | ||
| 267 | |||
| 225 | #ifndef Omit_Private_Memory | 268 | #ifndef Omit_Private_Memory |
| 226 | #ifndef PRIVATE_MEM | 269 | #ifndef PRIVATE_MEM |
| 227 | #define PRIVATE_MEM 2304 | 270 | #define PRIVATE_MEM 2304 |
| @@ -251,6 +294,15 @@ static double private_mem[PRIVATE_mem], *pmem_next = private_mem; | |||
| 251 | 294 | ||
| 252 | #include "errno.h" | 295 | #include "errno.h" |
| 253 | 296 | ||
| 297 | #ifdef NO_ERRNO /*{*/ | ||
| 298 | #undef Set_errno | ||
| 299 | #define Set_errno(x) | ||
| 300 | #else | ||
| 301 | #ifndef Set_errno | ||
| 302 | #define Set_errno(x) errno = x | ||
| 303 | #endif | ||
| 304 | #endif /*}*/ | ||
| 305 | |||
| 254 | #ifdef Bad_float_h | 306 | #ifdef Bad_float_h |
| 255 | 307 | ||
| 256 | #ifdef IEEE_Arith | 308 | #ifdef IEEE_Arith |
| @@ -292,19 +344,966 @@ static double private_mem[PRIVATE_mem], *pmem_next = private_mem; | |||
| 292 | extern "C" { | 344 | extern "C" { |
| 293 | #endif | 345 | #endif |
| 294 | 346 | ||
| 295 | #ifndef CONST | ||
| 296 | #ifdef KR_headers | ||
| 297 | #define CONST /* blank */ | ||
| 298 | #else | ||
| 299 | #define CONST const | ||
| 300 | #endif | ||
| 301 | #endif | ||
| 302 | |||
| 303 | #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 | 347 | #if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 |
| 304 | Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. | 348 | Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. |
| 305 | #endif | 349 | #endif |
| 306 | 350 | ||
| 307 | typedef union { double d; ULong L[2]; } U; | 351 | #undef USE_BF96 |
| 352 | |||
| 353 | #ifdef NO_LONG_LONG /*{{*/ | ||
| 354 | #undef ULLong | ||
| 355 | #ifdef Just_16 | ||
| 356 | #undef Pack_32 | ||
| 357 | /* When Pack_32 is not defined, we store 16 bits per 32-bit Long. | ||
| 358 | * This makes some inner loops simpler and sometimes saves work | ||
| 359 | * during multiplications, but it often seems to make things slightly | ||
| 360 | * slower. Hence the default is now to store 32 bits per Long. | ||
| 361 | */ | ||
| 362 | #endif | ||
| 363 | #else /*}{ long long available */ | ||
| 364 | #ifndef Llong | ||
| 365 | #define Llong long long | ||
| 366 | #endif | ||
| 367 | #ifndef ULLong | ||
| 368 | #define ULLong unsigned Llong | ||
| 369 | #endif | ||
| 370 | #ifndef NO_BF96 /*{*/ | ||
| 371 | #define USE_BF96 | ||
| 372 | |||
| 373 | #ifdef SET_INEXACT | ||
| 374 | #define dtoa_divmax 27 | ||
| 375 | #else | ||
| 376 | int dtoa_divmax = 2; /* Permit experimenting: on some systems, 64-bit integer */ | ||
| 377 | /* division is slow enough that we may sometimes want to */ | ||
| 378 | /* avoid using it. We assume (but do not check) that */ | ||
| 379 | /* dtoa_divmax <= 27.*/ | ||
| 380 | #endif | ||
| 381 | |||
| 382 | typedef struct BF96 { /* Normalized 96-bit software floating point numbers */ | ||
| 383 | unsigned int b0,b1,b2; /* b0 = most significant, binary point just to its left */ | ||
| 384 | int e; /* number represented = b * 2^e, with .5 <= b < 1 */ | ||
| 385 | } BF96; | ||
| 386 | |||
| 387 | static BF96 pten[667] = { | ||
| 388 | { 0xeef453d6, 0x923bd65a, 0x113faa29, -1136 }, | ||
| 389 | { 0x9558b466, 0x1b6565f8, 0x4ac7ca59, -1132 }, | ||
| 390 | { 0xbaaee17f, 0xa23ebf76, 0x5d79bcf0, -1129 }, | ||
| 391 | { 0xe95a99df, 0x8ace6f53, 0xf4d82c2c, -1126 }, | ||
| 392 | { 0x91d8a02b, 0xb6c10594, 0x79071b9b, -1122 }, | ||
| 393 | { 0xb64ec836, 0xa47146f9, 0x9748e282, -1119 }, | ||
| 394 | { 0xe3e27a44, 0x4d8d98b7, 0xfd1b1b23, -1116 }, | ||
| 395 | { 0x8e6d8c6a, 0xb0787f72, 0xfe30f0f5, -1112 }, | ||
| 396 | { 0xb208ef85, 0x5c969f4f, 0xbdbd2d33, -1109 }, | ||
| 397 | { 0xde8b2b66, 0xb3bc4723, 0xad2c7880, -1106 }, | ||
| 398 | { 0x8b16fb20, 0x3055ac76, 0x4c3bcb50, -1102 }, | ||
| 399 | { 0xaddcb9e8, 0x3c6b1793, 0xdf4abe24, -1099 }, | ||
| 400 | { 0xd953e862, 0x4b85dd78, 0xd71d6dad, -1096 }, | ||
| 401 | { 0x87d4713d, 0x6f33aa6b, 0x8672648c, -1092 }, | ||
| 402 | { 0xa9c98d8c, 0xcb009506, 0x680efdaf, -1089 }, | ||
| 403 | { 0xd43bf0ef, 0xfdc0ba48, 0x0212bd1b, -1086 }, | ||
| 404 | { 0x84a57695, 0xfe98746d, 0x014bb630, -1082 }, | ||
| 405 | { 0xa5ced43b, 0x7e3e9188, 0x419ea3bd, -1079 }, | ||
| 406 | { 0xcf42894a, 0x5dce35ea, 0x52064cac, -1076 }, | ||
| 407 | { 0x818995ce, 0x7aa0e1b2, 0x7343efeb, -1072 }, | ||
| 408 | { 0xa1ebfb42, 0x19491a1f, 0x1014ebe6, -1069 }, | ||
| 409 | { 0xca66fa12, 0x9f9b60a6, 0xd41a26e0, -1066 }, | ||
| 410 | { 0xfd00b897, 0x478238d0, 0x8920b098, -1063 }, | ||
| 411 | { 0x9e20735e, 0x8cb16382, 0x55b46e5f, -1059 }, | ||
| 412 | { 0xc5a89036, 0x2fddbc62, 0xeb2189f7, -1056 }, | ||
| 413 | { 0xf712b443, 0xbbd52b7b, 0xa5e9ec75, -1053 }, | ||
| 414 | { 0x9a6bb0aa, 0x55653b2d, 0x47b233c9, -1049 }, | ||
| 415 | { 0xc1069cd4, 0xeabe89f8, 0x999ec0bb, -1046 }, | ||
| 416 | { 0xf148440a, 0x256e2c76, 0xc00670ea, -1043 }, | ||
| 417 | { 0x96cd2a86, 0x5764dbca, 0x38040692, -1039 }, | ||
| 418 | { 0xbc807527, 0xed3e12bc, 0xc6050837, -1036 }, | ||
| 419 | { 0xeba09271, 0xe88d976b, 0xf7864a44, -1033 }, | ||
| 420 | { 0x93445b87, 0x31587ea3, 0x7ab3ee6a, -1029 }, | ||
| 421 | { 0xb8157268, 0xfdae9e4c, 0x5960ea05, -1026 }, | ||
| 422 | { 0xe61acf03, 0x3d1a45df, 0x6fb92487, -1023 }, | ||
| 423 | { 0x8fd0c162, 0x06306bab, 0xa5d3b6d4, -1019 }, | ||
| 424 | { 0xb3c4f1ba, 0x87bc8696, 0x8f48a489, -1016 }, | ||
| 425 | { 0xe0b62e29, 0x29aba83c, 0x331acdab, -1013 }, | ||
| 426 | { 0x8c71dcd9, 0xba0b4925, 0x9ff0c08b, -1009 }, | ||
| 427 | { 0xaf8e5410, 0x288e1b6f, 0x07ecf0ae, -1006 }, | ||
| 428 | { 0xdb71e914, 0x32b1a24a, 0xc9e82cd9, -1003 }, | ||
| 429 | { 0x892731ac, 0x9faf056e, 0xbe311c08, -999 }, | ||
| 430 | { 0xab70fe17, 0xc79ac6ca, 0x6dbd630a, -996 }, | ||
| 431 | { 0xd64d3d9d, 0xb981787d, 0x092cbbcc, -993 }, | ||
| 432 | { 0x85f04682, 0x93f0eb4e, 0x25bbf560, -989 }, | ||
| 433 | { 0xa76c5823, 0x38ed2621, 0xaf2af2b8, -986 }, | ||
| 434 | { 0xd1476e2c, 0x07286faa, 0x1af5af66, -983 }, | ||
| 435 | { 0x82cca4db, 0x847945ca, 0x50d98d9f, -979 }, | ||
| 436 | { 0xa37fce12, 0x6597973c, 0xe50ff107, -976 }, | ||
| 437 | { 0xcc5fc196, 0xfefd7d0c, 0x1e53ed49, -973 }, | ||
| 438 | { 0xff77b1fc, 0xbebcdc4f, 0x25e8e89c, -970 }, | ||
| 439 | { 0x9faacf3d, 0xf73609b1, 0x77b19161, -966 }, | ||
| 440 | { 0xc795830d, 0x75038c1d, 0xd59df5b9, -963 }, | ||
| 441 | { 0xf97ae3d0, 0xd2446f25, 0x4b057328, -960 }, | ||
| 442 | { 0x9becce62, 0x836ac577, 0x4ee367f9, -956 }, | ||
| 443 | { 0xc2e801fb, 0x244576d5, 0x229c41f7, -953 }, | ||
| 444 | { 0xf3a20279, 0xed56d48a, 0x6b435275, -950 }, | ||
| 445 | { 0x9845418c, 0x345644d6, 0x830a1389, -946 }, | ||
| 446 | { 0xbe5691ef, 0x416bd60c, 0x23cc986b, -943 }, | ||
| 447 | { 0xedec366b, 0x11c6cb8f, 0x2cbfbe86, -940 }, | ||
| 448 | { 0x94b3a202, 0xeb1c3f39, 0x7bf7d714, -936 }, | ||
| 449 | { 0xb9e08a83, 0xa5e34f07, 0xdaf5ccd9, -933 }, | ||
| 450 | { 0xe858ad24, 0x8f5c22c9, 0xd1b3400f, -930 }, | ||
| 451 | { 0x91376c36, 0xd99995be, 0x23100809, -926 }, | ||
| 452 | { 0xb5854744, 0x8ffffb2d, 0xabd40a0c, -923 }, | ||
| 453 | { 0xe2e69915, 0xb3fff9f9, 0x16c90c8f, -920 }, | ||
| 454 | { 0x8dd01fad, 0x907ffc3b, 0xae3da7d9, -916 }, | ||
| 455 | { 0xb1442798, 0xf49ffb4a, 0x99cd11cf, -913 }, | ||
| 456 | { 0xdd95317f, 0x31c7fa1d, 0x40405643, -910 }, | ||
| 457 | { 0x8a7d3eef, 0x7f1cfc52, 0x482835ea, -906 }, | ||
| 458 | { 0xad1c8eab, 0x5ee43b66, 0xda324365, -903 }, | ||
| 459 | { 0xd863b256, 0x369d4a40, 0x90bed43e, -900 }, | ||
| 460 | { 0x873e4f75, 0xe2224e68, 0x5a7744a6, -896 }, | ||
| 461 | { 0xa90de353, 0x5aaae202, 0x711515d0, -893 }, | ||
| 462 | { 0xd3515c28, 0x31559a83, 0x0d5a5b44, -890 }, | ||
| 463 | { 0x8412d999, 0x1ed58091, 0xe858790a, -886 }, | ||
| 464 | { 0xa5178fff, 0x668ae0b6, 0x626e974d, -883 }, | ||
| 465 | { 0xce5d73ff, 0x402d98e3, 0xfb0a3d21, -880 }, | ||
| 466 | { 0x80fa687f, 0x881c7f8e, 0x7ce66634, -876 }, | ||
| 467 | { 0xa139029f, 0x6a239f72, 0x1c1fffc1, -873 }, | ||
| 468 | { 0xc9874347, 0x44ac874e, 0xa327ffb2, -870 }, | ||
| 469 | { 0xfbe91419, 0x15d7a922, 0x4bf1ff9f, -867 }, | ||
| 470 | { 0x9d71ac8f, 0xada6c9b5, 0x6f773fc3, -863 }, | ||
| 471 | { 0xc4ce17b3, 0x99107c22, 0xcb550fb4, -860 }, | ||
| 472 | { 0xf6019da0, 0x7f549b2b, 0x7e2a53a1, -857 }, | ||
| 473 | { 0x99c10284, 0x4f94e0fb, 0x2eda7444, -853 }, | ||
| 474 | { 0xc0314325, 0x637a1939, 0xfa911155, -850 }, | ||
| 475 | { 0xf03d93ee, 0xbc589f88, 0x793555ab, -847 }, | ||
| 476 | { 0x96267c75, 0x35b763b5, 0x4bc1558b, -843 }, | ||
| 477 | { 0xbbb01b92, 0x83253ca2, 0x9eb1aaed, -840 }, | ||
| 478 | { 0xea9c2277, 0x23ee8bcb, 0x465e15a9, -837 }, | ||
| 479 | { 0x92a1958a, 0x7675175f, 0x0bfacd89, -833 }, | ||
| 480 | { 0xb749faed, 0x14125d36, 0xcef980ec, -830 }, | ||
| 481 | { 0xe51c79a8, 0x5916f484, 0x82b7e127, -827 }, | ||
| 482 | { 0x8f31cc09, 0x37ae58d2, 0xd1b2ecb8, -823 }, | ||
| 483 | { 0xb2fe3f0b, 0x8599ef07, 0x861fa7e6, -820 }, | ||
| 484 | { 0xdfbdcece, 0x67006ac9, 0x67a791e0, -817 }, | ||
| 485 | { 0x8bd6a141, 0x006042bd, 0xe0c8bb2c, -813 }, | ||
| 486 | { 0xaecc4991, 0x4078536d, 0x58fae9f7, -810 }, | ||
| 487 | { 0xda7f5bf5, 0x90966848, 0xaf39a475, -807 }, | ||
| 488 | { 0x888f9979, 0x7a5e012d, 0x6d8406c9, -803 }, | ||
| 489 | { 0xaab37fd7, 0xd8f58178, 0xc8e5087b, -800 }, | ||
| 490 | { 0xd5605fcd, 0xcf32e1d6, 0xfb1e4a9a, -797 }, | ||
| 491 | { 0x855c3be0, 0xa17fcd26, 0x5cf2eea0, -793 }, | ||
| 492 | { 0xa6b34ad8, 0xc9dfc06f, 0xf42faa48, -790 }, | ||
| 493 | { 0xd0601d8e, 0xfc57b08b, 0xf13b94da, -787 }, | ||
| 494 | { 0x823c1279, 0x5db6ce57, 0x76c53d08, -783 }, | ||
| 495 | { 0xa2cb1717, 0xb52481ed, 0x54768c4b, -780 }, | ||
| 496 | { 0xcb7ddcdd, 0xa26da268, 0xa9942f5d, -777 }, | ||
| 497 | { 0xfe5d5415, 0x0b090b02, 0xd3f93b35, -774 }, | ||
| 498 | { 0x9efa548d, 0x26e5a6e1, 0xc47bc501, -770 }, | ||
| 499 | { 0xc6b8e9b0, 0x709f109a, 0x359ab641, -767 }, | ||
| 500 | { 0xf867241c, 0x8cc6d4c0, 0xc30163d2, -764 }, | ||
| 501 | { 0x9b407691, 0xd7fc44f8, 0x79e0de63, -760 }, | ||
| 502 | { 0xc2109436, 0x4dfb5636, 0x985915fc, -757 }, | ||
| 503 | { 0xf294b943, 0xe17a2bc4, 0x3e6f5b7b, -754 }, | ||
| 504 | { 0x979cf3ca, 0x6cec5b5a, 0xa705992c, -750 }, | ||
| 505 | { 0xbd8430bd, 0x08277231, 0x50c6ff78, -747 }, | ||
| 506 | { 0xece53cec, 0x4a314ebd, 0xa4f8bf56, -744 }, | ||
| 507 | { 0x940f4613, 0xae5ed136, 0x871b7795, -740 }, | ||
| 508 | { 0xb9131798, 0x99f68584, 0x28e2557b, -737 }, | ||
| 509 | { 0xe757dd7e, 0xc07426e5, 0x331aeada, -734 }, | ||
| 510 | { 0x9096ea6f, 0x3848984f, 0x3ff0d2c8, -730 }, | ||
| 511 | { 0xb4bca50b, 0x065abe63, 0x0fed077a, -727 }, | ||
| 512 | { 0xe1ebce4d, 0xc7f16dfb, 0xd3e84959, -724 }, | ||
| 513 | { 0x8d3360f0, 0x9cf6e4bd, 0x64712dd7, -720 }, | ||
| 514 | { 0xb080392c, 0xc4349dec, 0xbd8d794d, -717 }, | ||
| 515 | { 0xdca04777, 0xf541c567, 0xecf0d7a0, -714 }, | ||
| 516 | { 0x89e42caa, 0xf9491b60, 0xf41686c4, -710 }, | ||
| 517 | { 0xac5d37d5, 0xb79b6239, 0x311c2875, -707 }, | ||
| 518 | { 0xd77485cb, 0x25823ac7, 0x7d633293, -704 }, | ||
| 519 | { 0x86a8d39e, 0xf77164bc, 0xae5dff9c, -700 }, | ||
| 520 | { 0xa8530886, 0xb54dbdeb, 0xd9f57f83, -697 }, | ||
| 521 | { 0xd267caa8, 0x62a12d66, 0xd072df63, -694 }, | ||
| 522 | { 0x8380dea9, 0x3da4bc60, 0x4247cb9e, -690 }, | ||
| 523 | { 0xa4611653, 0x8d0deb78, 0x52d9be85, -687 }, | ||
| 524 | { 0xcd795be8, 0x70516656, 0x67902e27, -684 }, | ||
| 525 | { 0x806bd971, 0x4632dff6, 0x00ba1cd8, -680 }, | ||
| 526 | { 0xa086cfcd, 0x97bf97f3, 0x80e8a40e, -677 }, | ||
| 527 | { 0xc8a883c0, 0xfdaf7df0, 0x6122cd12, -674 }, | ||
| 528 | { 0xfad2a4b1, 0x3d1b5d6c, 0x796b8057, -671 }, | ||
| 529 | { 0x9cc3a6ee, 0xc6311a63, 0xcbe33036, -667 }, | ||
| 530 | { 0xc3f490aa, 0x77bd60fc, 0xbedbfc44, -664 }, | ||
| 531 | { 0xf4f1b4d5, 0x15acb93b, 0xee92fb55, -661 }, | ||
| 532 | { 0x99171105, 0x2d8bf3c5, 0x751bdd15, -657 }, | ||
| 533 | { 0xbf5cd546, 0x78eef0b6, 0xd262d45a, -654 }, | ||
| 534 | { 0xef340a98, 0x172aace4, 0x86fb8971, -651 }, | ||
| 535 | { 0x9580869f, 0x0e7aac0e, 0xd45d35e6, -647 }, | ||
| 536 | { 0xbae0a846, 0xd2195712, 0x89748360, -644 }, | ||
| 537 | { 0xe998d258, 0x869facd7, 0x2bd1a438, -641 }, | ||
| 538 | { 0x91ff8377, 0x5423cc06, 0x7b6306a3, -637 }, | ||
| 539 | { 0xb67f6455, 0x292cbf08, 0x1a3bc84c, -634 }, | ||
| 540 | { 0xe41f3d6a, 0x7377eeca, 0x20caba5f, -631 }, | ||
| 541 | { 0x8e938662, 0x882af53e, 0x547eb47b, -627 }, | ||
| 542 | { 0xb23867fb, 0x2a35b28d, 0xe99e619a, -624 }, | ||
| 543 | { 0xdec681f9, 0xf4c31f31, 0x6405fa00, -621 }, | ||
| 544 | { 0x8b3c113c, 0x38f9f37e, 0xde83bc40, -617 }, | ||
| 545 | { 0xae0b158b, 0x4738705e, 0x9624ab50, -614 }, | ||
| 546 | { 0xd98ddaee, 0x19068c76, 0x3badd624, -611 }, | ||
| 547 | { 0x87f8a8d4, 0xcfa417c9, 0xe54ca5d7, -607 }, | ||
| 548 | { 0xa9f6d30a, 0x038d1dbc, 0x5e9fcf4c, -604 }, | ||
| 549 | { 0xd47487cc, 0x8470652b, 0x7647c320, -601 }, | ||
| 550 | { 0x84c8d4df, 0xd2c63f3b, 0x29ecd9f4, -597 }, | ||
| 551 | { 0xa5fb0a17, 0xc777cf09, 0xf4681071, -594 }, | ||
| 552 | { 0xcf79cc9d, 0xb955c2cc, 0x7182148d, -591 }, | ||
| 553 | { 0x81ac1fe2, 0x93d599bf, 0xc6f14cd8, -587 }, | ||
| 554 | { 0xa21727db, 0x38cb002f, 0xb8ada00e, -584 }, | ||
| 555 | { 0xca9cf1d2, 0x06fdc03b, 0xa6d90811, -581 }, | ||
| 556 | { 0xfd442e46, 0x88bd304a, 0x908f4a16, -578 }, | ||
| 557 | { 0x9e4a9cec, 0x15763e2e, 0x9a598e4e, -574 }, | ||
| 558 | { 0xc5dd4427, 0x1ad3cdba, 0x40eff1e1, -571 }, | ||
| 559 | { 0xf7549530, 0xe188c128, 0xd12bee59, -568 }, | ||
| 560 | { 0x9a94dd3e, 0x8cf578b9, 0x82bb74f8, -564 }, | ||
| 561 | { 0xc13a148e, 0x3032d6e7, 0xe36a5236, -561 }, | ||
| 562 | { 0xf18899b1, 0xbc3f8ca1, 0xdc44e6c3, -558 }, | ||
| 563 | { 0x96f5600f, 0x15a7b7e5, 0x29ab103a, -554 }, | ||
| 564 | { 0xbcb2b812, 0xdb11a5de, 0x7415d448, -551 }, | ||
| 565 | { 0xebdf6617, 0x91d60f56, 0x111b495b, -548 }, | ||
| 566 | { 0x936b9fce, 0xbb25c995, 0xcab10dd9, -544 }, | ||
| 567 | { 0xb84687c2, 0x69ef3bfb, 0x3d5d514f, -541 }, | ||
| 568 | { 0xe65829b3, 0x046b0afa, 0x0cb4a5a3, -538 }, | ||
| 569 | { 0x8ff71a0f, 0xe2c2e6dc, 0x47f0e785, -534 }, | ||
| 570 | { 0xb3f4e093, 0xdb73a093, 0x59ed2167, -531 }, | ||
| 571 | { 0xe0f218b8, 0xd25088b8, 0x306869c1, -528 }, | ||
| 572 | { 0x8c974f73, 0x83725573, 0x1e414218, -524 }, | ||
| 573 | { 0xafbd2350, 0x644eeacf, 0xe5d1929e, -521 }, | ||
| 574 | { 0xdbac6c24, 0x7d62a583, 0xdf45f746, -518 }, | ||
| 575 | { 0x894bc396, 0xce5da772, 0x6b8bba8c, -514 }, | ||
| 576 | { 0xab9eb47c, 0x81f5114f, 0x066ea92f, -511 }, | ||
| 577 | { 0xd686619b, 0xa27255a2, 0xc80a537b, -508 }, | ||
| 578 | { 0x8613fd01, 0x45877585, 0xbd06742c, -504 }, | ||
| 579 | { 0xa798fc41, 0x96e952e7, 0x2c481138, -501 }, | ||
| 580 | { 0xd17f3b51, 0xfca3a7a0, 0xf75a1586, -498 }, | ||
| 581 | { 0x82ef8513, 0x3de648c4, 0x9a984d73, -494 }, | ||
| 582 | { 0xa3ab6658, 0x0d5fdaf5, 0xc13e60d0, -491 }, | ||
| 583 | { 0xcc963fee, 0x10b7d1b3, 0x318df905, -488 }, | ||
| 584 | { 0xffbbcfe9, 0x94e5c61f, 0xfdf17746, -485 }, | ||
| 585 | { 0x9fd561f1, 0xfd0f9bd3, 0xfeb6ea8b, -481 }, | ||
| 586 | { 0xc7caba6e, 0x7c5382c8, 0xfe64a52e, -478 }, | ||
| 587 | { 0xf9bd690a, 0x1b68637b, 0x3dfdce7a, -475 }, | ||
| 588 | { 0x9c1661a6, 0x51213e2d, 0x06bea10c, -471 }, | ||
| 589 | { 0xc31bfa0f, 0xe5698db8, 0x486e494f, -468 }, | ||
| 590 | { 0xf3e2f893, 0xdec3f126, 0x5a89dba3, -465 }, | ||
| 591 | { 0x986ddb5c, 0x6b3a76b7, 0xf8962946, -461 }, | ||
| 592 | { 0xbe895233, 0x86091465, 0xf6bbb397, -458 }, | ||
| 593 | { 0xee2ba6c0, 0x678b597f, 0x746aa07d, -455 }, | ||
| 594 | { 0x94db4838, 0x40b717ef, 0xa8c2a44e, -451 }, | ||
| 595 | { 0xba121a46, 0x50e4ddeb, 0x92f34d62, -448 }, | ||
| 596 | { 0xe896a0d7, 0xe51e1566, 0x77b020ba, -445 }, | ||
| 597 | { 0x915e2486, 0xef32cd60, 0x0ace1474, -441 }, | ||
| 598 | { 0xb5b5ada8, 0xaaff80b8, 0x0d819992, -438 }, | ||
| 599 | { 0xe3231912, 0xd5bf60e6, 0x10e1fff6, -435 }, | ||
| 600 | { 0x8df5efab, 0xc5979c8f, 0xca8d3ffa, -431 }, | ||
| 601 | { 0xb1736b96, 0xb6fd83b3, 0xbd308ff8, -428 }, | ||
| 602 | { 0xddd0467c, 0x64bce4a0, 0xac7cb3f6, -425 }, | ||
| 603 | { 0x8aa22c0d, 0xbef60ee4, 0x6bcdf07a, -421 }, | ||
| 604 | { 0xad4ab711, 0x2eb3929d, 0x86c16c98, -418 }, | ||
| 605 | { 0xd89d64d5, 0x7a607744, 0xe871c7bf, -415 }, | ||
| 606 | { 0x87625f05, 0x6c7c4a8b, 0x11471cd7, -411 }, | ||
| 607 | { 0xa93af6c6, 0xc79b5d2d, 0xd598e40d, -408 }, | ||
| 608 | { 0xd389b478, 0x79823479, 0x4aff1d10, -405 }, | ||
| 609 | { 0x843610cb, 0x4bf160cb, 0xcedf722a, -401 }, | ||
| 610 | { 0xa54394fe, 0x1eedb8fe, 0xc2974eb4, -398 }, | ||
| 611 | { 0xce947a3d, 0xa6a9273e, 0x733d2262, -395 }, | ||
| 612 | { 0x811ccc66, 0x8829b887, 0x0806357d, -391 }, | ||
| 613 | { 0xa163ff80, 0x2a3426a8, 0xca07c2dc, -388 }, | ||
| 614 | { 0xc9bcff60, 0x34c13052, 0xfc89b393, -385 }, | ||
| 615 | { 0xfc2c3f38, 0x41f17c67, 0xbbac2078, -382 }, | ||
| 616 | { 0x9d9ba783, 0x2936edc0, 0xd54b944b, -378 }, | ||
| 617 | { 0xc5029163, 0xf384a931, 0x0a9e795e, -375 }, | ||
| 618 | { 0xf64335bc, 0xf065d37d, 0x4d4617b5, -372 }, | ||
| 619 | { 0x99ea0196, 0x163fa42e, 0x504bced1, -368 }, | ||
| 620 | { 0xc06481fb, 0x9bcf8d39, 0xe45ec286, -365 }, | ||
| 621 | { 0xf07da27a, 0x82c37088, 0x5d767327, -362 }, | ||
| 622 | { 0x964e858c, 0x91ba2655, 0x3a6a07f8, -358 }, | ||
| 623 | { 0xbbe226ef, 0xb628afea, 0x890489f7, -355 }, | ||
| 624 | { 0xeadab0ab, 0xa3b2dbe5, 0x2b45ac74, -352 }, | ||
| 625 | { 0x92c8ae6b, 0x464fc96f, 0x3b0b8bc9, -348 }, | ||
| 626 | { 0xb77ada06, 0x17e3bbcb, 0x09ce6ebb, -345 }, | ||
| 627 | { 0xe5599087, 0x9ddcaabd, 0xcc420a6a, -342 }, | ||
| 628 | { 0x8f57fa54, 0xc2a9eab6, 0x9fa94682, -338 }, | ||
| 629 | { 0xb32df8e9, 0xf3546564, 0x47939822, -335 }, | ||
| 630 | { 0xdff97724, 0x70297ebd, 0x59787e2b, -332 }, | ||
| 631 | { 0x8bfbea76, 0xc619ef36, 0x57eb4edb, -328 }, | ||
| 632 | { 0xaefae514, 0x77a06b03, 0xede62292, -325 }, | ||
| 633 | { 0xdab99e59, 0x958885c4, 0xe95fab36, -322 }, | ||
| 634 | { 0x88b402f7, 0xfd75539b, 0x11dbcb02, -318 }, | ||
| 635 | { 0xaae103b5, 0xfcd2a881, 0xd652bdc2, -315 }, | ||
| 636 | { 0xd59944a3, 0x7c0752a2, 0x4be76d33, -312 }, | ||
| 637 | { 0x857fcae6, 0x2d8493a5, 0x6f70a440, -308 }, | ||
| 638 | { 0xa6dfbd9f, 0xb8e5b88e, 0xcb4ccd50, -305 }, | ||
| 639 | { 0xd097ad07, 0xa71f26b2, 0x7e2000a4, -302 }, | ||
| 640 | { 0x825ecc24, 0xc873782f, 0x8ed40066, -298 }, | ||
| 641 | { 0xa2f67f2d, 0xfa90563b, 0x72890080, -295 }, | ||
| 642 | { 0xcbb41ef9, 0x79346bca, 0x4f2b40a0, -292 }, | ||
| 643 | { 0xfea126b7, 0xd78186bc, 0xe2f610c8, -289 }, | ||
| 644 | { 0x9f24b832, 0xe6b0f436, 0x0dd9ca7d, -285 }, | ||
| 645 | { 0xc6ede63f, 0xa05d3143, 0x91503d1c, -282 }, | ||
| 646 | { 0xf8a95fcf, 0x88747d94, 0x75a44c63, -279 }, | ||
| 647 | { 0x9b69dbe1, 0xb548ce7c, 0xc986afbe, -275 }, | ||
| 648 | { 0xc24452da, 0x229b021b, 0xfbe85bad, -272 }, | ||
| 649 | { 0xf2d56790, 0xab41c2a2, 0xfae27299, -269 }, | ||
| 650 | { 0x97c560ba, 0x6b0919a5, 0xdccd879f, -265 }, | ||
| 651 | { 0xbdb6b8e9, 0x05cb600f, 0x5400e987, -262 }, | ||
| 652 | { 0xed246723, 0x473e3813, 0x290123e9, -259 }, | ||
| 653 | { 0x9436c076, 0x0c86e30b, 0xf9a0b672, -255 }, | ||
| 654 | { 0xb9447093, 0x8fa89bce, 0xf808e40e, -252 }, | ||
| 655 | { 0xe7958cb8, 0x7392c2c2, 0xb60b1d12, -249 }, | ||
| 656 | { 0x90bd77f3, 0x483bb9b9, 0xb1c6f22b, -245 }, | ||
| 657 | { 0xb4ecd5f0, 0x1a4aa828, 0x1e38aeb6, -242 }, | ||
| 658 | { 0xe2280b6c, 0x20dd5232, 0x25c6da63, -239 }, | ||
| 659 | { 0x8d590723, 0x948a535f, 0x579c487e, -235 }, | ||
| 660 | { 0xb0af48ec, 0x79ace837, 0x2d835a9d, -232 }, | ||
| 661 | { 0xdcdb1b27, 0x98182244, 0xf8e43145, -229 }, | ||
| 662 | { 0x8a08f0f8, 0xbf0f156b, 0x1b8e9ecb, -225 }, | ||
| 663 | { 0xac8b2d36, 0xeed2dac5, 0xe272467e, -222 }, | ||
| 664 | { 0xd7adf884, 0xaa879177, 0x5b0ed81d, -219 }, | ||
| 665 | { 0x86ccbb52, 0xea94baea, 0x98e94712, -215 }, | ||
| 666 | { 0xa87fea27, 0xa539e9a5, 0x3f2398d7, -212 }, | ||
| 667 | { 0xd29fe4b1, 0x8e88640e, 0x8eec7f0d, -209 }, | ||
| 668 | { 0x83a3eeee, 0xf9153e89, 0x1953cf68, -205 }, | ||
| 669 | { 0xa48ceaaa, 0xb75a8e2b, 0x5fa8c342, -202 }, | ||
| 670 | { 0xcdb02555, 0x653131b6, 0x3792f412, -199 }, | ||
| 671 | { 0x808e1755, 0x5f3ebf11, 0xe2bbd88b, -195 }, | ||
| 672 | { 0xa0b19d2a, 0xb70e6ed6, 0x5b6aceae, -192 }, | ||
| 673 | { 0xc8de0475, 0x64d20a8b, 0xf245825a, -189 }, | ||
| 674 | { 0xfb158592, 0xbe068d2e, 0xeed6e2f0, -186 }, | ||
| 675 | { 0x9ced737b, 0xb6c4183d, 0x55464dd6, -182 }, | ||
| 676 | { 0xc428d05a, 0xa4751e4c, 0xaa97e14c, -179 }, | ||
| 677 | { 0xf5330471, 0x4d9265df, 0xd53dd99f, -176 }, | ||
| 678 | { 0x993fe2c6, 0xd07b7fab, 0xe546a803, -172 }, | ||
| 679 | { 0xbf8fdb78, 0x849a5f96, 0xde985204, -169 }, | ||
| 680 | { 0xef73d256, 0xa5c0f77c, 0x963e6685, -166 }, | ||
| 681 | { 0x95a86376, 0x27989aad, 0xdde70013, -162 }, | ||
| 682 | { 0xbb127c53, 0xb17ec159, 0x5560c018, -159 }, | ||
| 683 | { 0xe9d71b68, 0x9dde71af, 0xaab8f01e, -156 }, | ||
| 684 | { 0x92267121, 0x62ab070d, 0xcab39613, -152 }, | ||
| 685 | { 0xb6b00d69, 0xbb55c8d1, 0x3d607b97, -149 }, | ||
| 686 | { 0xe45c10c4, 0x2a2b3b05, 0x8cb89a7d, -146 }, | ||
| 687 | { 0x8eb98a7a, 0x9a5b04e3, 0x77f3608e, -142 }, | ||
| 688 | { 0xb267ed19, 0x40f1c61c, 0x55f038b2, -139 }, | ||
| 689 | { 0xdf01e85f, 0x912e37a3, 0x6b6c46de, -136 }, | ||
| 690 | { 0x8b61313b, 0xbabce2c6, 0x2323ac4b, -132 }, | ||
| 691 | { 0xae397d8a, 0xa96c1b77, 0xabec975e, -129 }, | ||
| 692 | { 0xd9c7dced, 0x53c72255, 0x96e7bd35, -126 }, | ||
| 693 | { 0x881cea14, 0x545c7575, 0x7e50d641, -122 }, | ||
| 694 | { 0xaa242499, 0x697392d2, 0xdde50bd1, -119 }, | ||
| 695 | { 0xd4ad2dbf, 0xc3d07787, 0x955e4ec6, -116 }, | ||
| 696 | { 0x84ec3c97, 0xda624ab4, 0xbd5af13b, -112 }, | ||
| 697 | { 0xa6274bbd, 0xd0fadd61, 0xecb1ad8a, -109 }, | ||
| 698 | { 0xcfb11ead, 0x453994ba, 0x67de18ed, -106 }, | ||
| 699 | { 0x81ceb32c, 0x4b43fcf4, 0x80eacf94, -102 }, | ||
| 700 | { 0xa2425ff7, 0x5e14fc31, 0xa1258379, -99 }, | ||
| 701 | { 0xcad2f7f5, 0x359a3b3e, 0x096ee458, -96 }, | ||
| 702 | { 0xfd87b5f2, 0x8300ca0d, 0x8bca9d6e, -93 }, | ||
| 703 | { 0x9e74d1b7, 0x91e07e48, 0x775ea264, -89 }, | ||
| 704 | { 0xc6120625, 0x76589dda, 0x95364afe, -86 }, | ||
| 705 | { 0xf79687ae, 0xd3eec551, 0x3a83ddbd, -83 }, | ||
| 706 | { 0x9abe14cd, 0x44753b52, 0xc4926a96, -79 }, | ||
| 707 | { 0xc16d9a00, 0x95928a27, 0x75b7053c, -76 }, | ||
| 708 | { 0xf1c90080, 0xbaf72cb1, 0x5324c68b, -73 }, | ||
| 709 | { 0x971da050, 0x74da7bee, 0xd3f6fc16, -69 }, | ||
| 710 | { 0xbce50864, 0x92111aea, 0x88f4bb1c, -66 }, | ||
| 711 | { 0xec1e4a7d, 0xb69561a5, 0x2b31e9e3, -63 }, | ||
| 712 | { 0x9392ee8e, 0x921d5d07, 0x3aff322e, -59 }, | ||
| 713 | { 0xb877aa32, 0x36a4b449, 0x09befeb9, -56 }, | ||
| 714 | { 0xe69594be, 0xc44de15b, 0x4c2ebe68, -53 }, | ||
| 715 | { 0x901d7cf7, 0x3ab0acd9, 0x0f9d3701, -49 }, | ||
| 716 | { 0xb424dc35, 0x095cd80f, 0x538484c1, -46 }, | ||
| 717 | { 0xe12e1342, 0x4bb40e13, 0x2865a5f2, -43 }, | ||
| 718 | { 0x8cbccc09, 0x6f5088cb, 0xf93f87b7, -39 }, | ||
| 719 | { 0xafebff0b, 0xcb24aafe, 0xf78f69a5, -36 }, | ||
| 720 | { 0xdbe6fece, 0xbdedd5be, 0xb573440e, -33 }, | ||
| 721 | { 0x89705f41, 0x36b4a597, 0x31680a88, -29 }, | ||
| 722 | { 0xabcc7711, 0x8461cefc, 0xfdc20d2b, -26 }, | ||
| 723 | { 0xd6bf94d5, 0xe57a42bc, 0x3d329076, -23 }, | ||
| 724 | { 0x8637bd05, 0xaf6c69b5, 0xa63f9a49, -19 }, | ||
| 725 | { 0xa7c5ac47, 0x1b478423, 0x0fcf80dc, -16 }, | ||
| 726 | { 0xd1b71758, 0xe219652b, 0xd3c36113, -13 }, | ||
| 727 | { 0x83126e97, 0x8d4fdf3b, 0x645a1cac, -9 }, | ||
| 728 | { 0xa3d70a3d, 0x70a3d70a, 0x3d70a3d7, -6 }, | ||
| 729 | { 0xcccccccc, 0xcccccccc, 0xcccccccc, -3 }, | ||
| 730 | { 0x80000000, 0x00000000, 0x00000000, 1 }, | ||
| 731 | { 0xa0000000, 0x00000000, 0x00000000, 4 }, | ||
| 732 | { 0xc8000000, 0x00000000, 0x00000000, 7 }, | ||
| 733 | { 0xfa000000, 0x00000000, 0x00000000, 10 }, | ||
| 734 | { 0x9c400000, 0x00000000, 0x00000000, 14 }, | ||
| 735 | { 0xc3500000, 0x00000000, 0x00000000, 17 }, | ||
| 736 | { 0xf4240000, 0x00000000, 0x00000000, 20 }, | ||
| 737 | { 0x98968000, 0x00000000, 0x00000000, 24 }, | ||
| 738 | { 0xbebc2000, 0x00000000, 0x00000000, 27 }, | ||
| 739 | { 0xee6b2800, 0x00000000, 0x00000000, 30 }, | ||
| 740 | { 0x9502f900, 0x00000000, 0x00000000, 34 }, | ||
| 741 | { 0xba43b740, 0x00000000, 0x00000000, 37 }, | ||
| 742 | { 0xe8d4a510, 0x00000000, 0x00000000, 40 }, | ||
| 743 | { 0x9184e72a, 0x00000000, 0x00000000, 44 }, | ||
| 744 | { 0xb5e620f4, 0x80000000, 0x00000000, 47 }, | ||
| 745 | { 0xe35fa931, 0xa0000000, 0x00000000, 50 }, | ||
| 746 | { 0x8e1bc9bf, 0x04000000, 0x00000000, 54 }, | ||
| 747 | { 0xb1a2bc2e, 0xc5000000, 0x00000000, 57 }, | ||
| 748 | { 0xde0b6b3a, 0x76400000, 0x00000000, 60 }, | ||
| 749 | { 0x8ac72304, 0x89e80000, 0x00000000, 64 }, | ||
| 750 | { 0xad78ebc5, 0xac620000, 0x00000000, 67 }, | ||
| 751 | { 0xd8d726b7, 0x177a8000, 0x00000000, 70 }, | ||
| 752 | { 0x87867832, 0x6eac9000, 0x00000000, 74 }, | ||
| 753 | { 0xa968163f, 0x0a57b400, 0x00000000, 77 }, | ||
| 754 | { 0xd3c21bce, 0xcceda100, 0x00000000, 80 }, | ||
| 755 | { 0x84595161, 0x401484a0, 0x00000000, 84 }, | ||
| 756 | { 0xa56fa5b9, 0x9019a5c8, 0x00000000, 87 }, | ||
| 757 | { 0xcecb8f27, 0xf4200f3a, 0x00000000, 90 }, | ||
| 758 | { 0x813f3978, 0xf8940984, 0x40000000, 94 }, | ||
| 759 | { 0xa18f07d7, 0x36b90be5, 0x50000000, 97 }, | ||
| 760 | { 0xc9f2c9cd, 0x04674ede, 0xa4000000, 100 }, | ||
| 761 | { 0xfc6f7c40, 0x45812296, 0x4d000000, 103 }, | ||
| 762 | { 0x9dc5ada8, 0x2b70b59d, 0xf0200000, 107 }, | ||
| 763 | { 0xc5371912, 0x364ce305, 0x6c280000, 110 }, | ||
| 764 | { 0xf684df56, 0xc3e01bc6, 0xc7320000, 113 }, | ||
| 765 | { 0x9a130b96, 0x3a6c115c, 0x3c7f4000, 117 }, | ||
| 766 | { 0xc097ce7b, 0xc90715b3, 0x4b9f1000, 120 }, | ||
| 767 | { 0xf0bdc21a, 0xbb48db20, 0x1e86d400, 123 }, | ||
| 768 | { 0x96769950, 0xb50d88f4, 0x13144480, 127 }, | ||
| 769 | { 0xbc143fa4, 0xe250eb31, 0x17d955a0, 130 }, | ||
| 770 | { 0xeb194f8e, 0x1ae525fd, 0x5dcfab08, 133 }, | ||
| 771 | { 0x92efd1b8, 0xd0cf37be, 0x5aa1cae5, 137 }, | ||
| 772 | { 0xb7abc627, 0x050305ad, 0xf14a3d9e, 140 }, | ||
| 773 | { 0xe596b7b0, 0xc643c719, 0x6d9ccd05, 143 }, | ||
| 774 | { 0x8f7e32ce, 0x7bea5c6f, 0xe4820023, 147 }, | ||
| 775 | { 0xb35dbf82, 0x1ae4f38b, 0xdda2802c, 150 }, | ||
| 776 | { 0xe0352f62, 0xa19e306e, 0xd50b2037, 153 }, | ||
| 777 | { 0x8c213d9d, 0xa502de45, 0x4526f422, 157 }, | ||
| 778 | { 0xaf298d05, 0x0e4395d6, 0x9670b12b, 160 }, | ||
| 779 | { 0xdaf3f046, 0x51d47b4c, 0x3c0cdd76, 163 }, | ||
| 780 | { 0x88d8762b, 0xf324cd0f, 0xa5880a69, 167 }, | ||
| 781 | { 0xab0e93b6, 0xefee0053, 0x8eea0d04, 170 }, | ||
| 782 | { 0xd5d238a4, 0xabe98068, 0x72a49045, 173 }, | ||
| 783 | { 0x85a36366, 0xeb71f041, 0x47a6da2b, 177 }, | ||
| 784 | { 0xa70c3c40, 0xa64e6c51, 0x999090b6, 180 }, | ||
| 785 | { 0xd0cf4b50, 0xcfe20765, 0xfff4b4e3, 183 }, | ||
| 786 | { 0x82818f12, 0x81ed449f, 0xbff8f10e, 187 }, | ||
| 787 | { 0xa321f2d7, 0x226895c7, 0xaff72d52, 190 }, | ||
| 788 | { 0xcbea6f8c, 0xeb02bb39, 0x9bf4f8a6, 193 }, | ||
| 789 | { 0xfee50b70, 0x25c36a08, 0x02f236d0, 196 }, | ||
| 790 | { 0x9f4f2726, 0x179a2245, 0x01d76242, 200 }, | ||
| 791 | { 0xc722f0ef, 0x9d80aad6, 0x424d3ad2, 203 }, | ||
| 792 | { 0xf8ebad2b, 0x84e0d58b, 0xd2e08987, 206 }, | ||
| 793 | { 0x9b934c3b, 0x330c8577, 0x63cc55f4, 210 }, | ||
| 794 | { 0xc2781f49, 0xffcfa6d5, 0x3cbf6b71, 213 }, | ||
| 795 | { 0xf316271c, 0x7fc3908a, 0x8bef464e, 216 }, | ||
| 796 | { 0x97edd871, 0xcfda3a56, 0x97758bf0, 220 }, | ||
| 797 | { 0xbde94e8e, 0x43d0c8ec, 0x3d52eeed, 223 }, | ||
| 798 | { 0xed63a231, 0xd4c4fb27, 0x4ca7aaa8, 226 }, | ||
| 799 | { 0x945e455f, 0x24fb1cf8, 0x8fe8caa9, 230 }, | ||
| 800 | { 0xb975d6b6, 0xee39e436, 0xb3e2fd53, 233 }, | ||
| 801 | { 0xe7d34c64, 0xa9c85d44, 0x60dbbca8, 236 }, | ||
| 802 | { 0x90e40fbe, 0xea1d3a4a, 0xbc8955e9, 240 }, | ||
| 803 | { 0xb51d13ae, 0xa4a488dd, 0x6babab63, 243 }, | ||
| 804 | { 0xe264589a, 0x4dcdab14, 0xc696963c, 246 }, | ||
| 805 | { 0x8d7eb760, 0x70a08aec, 0xfc1e1de5, 250 }, | ||
| 806 | { 0xb0de6538, 0x8cc8ada8, 0x3b25a55f, 253 }, | ||
| 807 | { 0xdd15fe86, 0xaffad912, 0x49ef0eb7, 256 }, | ||
| 808 | { 0x8a2dbf14, 0x2dfcc7ab, 0x6e356932, 260 }, | ||
| 809 | { 0xacb92ed9, 0x397bf996, 0x49c2c37f, 263 }, | ||
| 810 | { 0xd7e77a8f, 0x87daf7fb, 0xdc33745e, 266 }, | ||
| 811 | { 0x86f0ac99, 0xb4e8dafd, 0x69a028bb, 270 }, | ||
| 812 | { 0xa8acd7c0, 0x222311bc, 0xc40832ea, 273 }, | ||
| 813 | { 0xd2d80db0, 0x2aabd62b, 0xf50a3fa4, 276 }, | ||
| 814 | { 0x83c7088e, 0x1aab65db, 0x792667c6, 280 }, | ||
| 815 | { 0xa4b8cab1, 0xa1563f52, 0x577001b8, 283 }, | ||
| 816 | { 0xcde6fd5e, 0x09abcf26, 0xed4c0226, 286 }, | ||
| 817 | { 0x80b05e5a, 0xc60b6178, 0x544f8158, 290 }, | ||
| 818 | { 0xa0dc75f1, 0x778e39d6, 0x696361ae, 293 }, | ||
| 819 | { 0xc913936d, 0xd571c84c, 0x03bc3a19, 296 }, | ||
| 820 | { 0xfb587849, 0x4ace3a5f, 0x04ab48a0, 299 }, | ||
| 821 | { 0x9d174b2d, 0xcec0e47b, 0x62eb0d64, 303 }, | ||
| 822 | { 0xc45d1df9, 0x42711d9a, 0x3ba5d0bd, 306 }, | ||
| 823 | { 0xf5746577, 0x930d6500, 0xca8f44ec, 309 }, | ||
| 824 | { 0x9968bf6a, 0xbbe85f20, 0x7e998b13, 313 }, | ||
| 825 | { 0xbfc2ef45, 0x6ae276e8, 0x9e3fedd8, 316 }, | ||
| 826 | { 0xefb3ab16, 0xc59b14a2, 0xc5cfe94e, 319 }, | ||
| 827 | { 0x95d04aee, 0x3b80ece5, 0xbba1f1d1, 323 }, | ||
| 828 | { 0xbb445da9, 0xca61281f, 0x2a8a6e45, 326 }, | ||
| 829 | { 0xea157514, 0x3cf97226, 0xf52d09d7, 329 }, | ||
| 830 | { 0x924d692c, 0xa61be758, 0x593c2626, 333 }, | ||
| 831 | { 0xb6e0c377, 0xcfa2e12e, 0x6f8b2fb0, 336 }, | ||
| 832 | { 0xe498f455, 0xc38b997a, 0x0b6dfb9c, 339 }, | ||
| 833 | { 0x8edf98b5, 0x9a373fec, 0x4724bd41, 343 }, | ||
| 834 | { 0xb2977ee3, 0x00c50fe7, 0x58edec91, 346 }, | ||
| 835 | { 0xdf3d5e9b, 0xc0f653e1, 0x2f2967b6, 349 }, | ||
| 836 | { 0x8b865b21, 0x5899f46c, 0xbd79e0d2, 353 }, | ||
| 837 | { 0xae67f1e9, 0xaec07187, 0xecd85906, 356 }, | ||
| 838 | { 0xda01ee64, 0x1a708de9, 0xe80e6f48, 359 }, | ||
| 839 | { 0x884134fe, 0x908658b2, 0x3109058d, 363 }, | ||
| 840 | { 0xaa51823e, 0x34a7eede, 0xbd4b46f0, 366 }, | ||
| 841 | { 0xd4e5e2cd, 0xc1d1ea96, 0x6c9e18ac, 369 }, | ||
| 842 | { 0x850fadc0, 0x9923329e, 0x03e2cf6b, 373 }, | ||
| 843 | { 0xa6539930, 0xbf6bff45, 0x84db8346, 376 }, | ||
| 844 | { 0xcfe87f7c, 0xef46ff16, 0xe6126418, 379 }, | ||
| 845 | { 0x81f14fae, 0x158c5f6e, 0x4fcb7e8f, 383 }, | ||
| 846 | { 0xa26da399, 0x9aef7749, 0xe3be5e33, 386 }, | ||
| 847 | { 0xcb090c80, 0x01ab551c, 0x5cadf5bf, 389 }, | ||
| 848 | { 0xfdcb4fa0, 0x02162a63, 0x73d9732f, 392 }, | ||
| 849 | { 0x9e9f11c4, 0x014dda7e, 0x2867e7fd, 396 }, | ||
| 850 | { 0xc646d635, 0x01a1511d, 0xb281e1fd, 399 }, | ||
| 851 | { 0xf7d88bc2, 0x4209a565, 0x1f225a7c, 402 }, | ||
| 852 | { 0x9ae75759, 0x6946075f, 0x3375788d, 406 }, | ||
| 853 | { 0xc1a12d2f, 0xc3978937, 0x0052d6b1, 409 }, | ||
| 854 | { 0xf209787b, 0xb47d6b84, 0xc0678c5d, 412 }, | ||
| 855 | { 0x9745eb4d, 0x50ce6332, 0xf840b7ba, 416 }, | ||
| 856 | { 0xbd176620, 0xa501fbff, 0xb650e5a9, 419 }, | ||
| 857 | { 0xec5d3fa8, 0xce427aff, 0xa3e51f13, 422 }, | ||
| 858 | { 0x93ba47c9, 0x80e98cdf, 0xc66f336c, 426 }, | ||
| 859 | { 0xb8a8d9bb, 0xe123f017, 0xb80b0047, 429 }, | ||
| 860 | { 0xe6d3102a, 0xd96cec1d, 0xa60dc059, 432 }, | ||
| 861 | { 0x9043ea1a, 0xc7e41392, 0x87c89837, 436 }, | ||
| 862 | { 0xb454e4a1, 0x79dd1877, 0x29babe45, 439 }, | ||
| 863 | { 0xe16a1dc9, 0xd8545e94, 0xf4296dd6, 442 }, | ||
| 864 | { 0x8ce2529e, 0x2734bb1d, 0x1899e4a6, 446 }, | ||
| 865 | { 0xb01ae745, 0xb101e9e4, 0x5ec05dcf, 449 }, | ||
| 866 | { 0xdc21a117, 0x1d42645d, 0x76707543, 452 }, | ||
| 867 | { 0x899504ae, 0x72497eba, 0x6a06494a, 456 }, | ||
| 868 | { 0xabfa45da, 0x0edbde69, 0x0487db9d, 459 }, | ||
| 869 | { 0xd6f8d750, 0x9292d603, 0x45a9d284, 462 }, | ||
| 870 | { 0x865b8692, 0x5b9bc5c2, 0x0b8a2392, 466 }, | ||
| 871 | { 0xa7f26836, 0xf282b732, 0x8e6cac77, 469 }, | ||
| 872 | { 0xd1ef0244, 0xaf2364ff, 0x3207d795, 472 }, | ||
| 873 | { 0x8335616a, 0xed761f1f, 0x7f44e6bd, 476 }, | ||
| 874 | { 0xa402b9c5, 0xa8d3a6e7, 0x5f16206c, 479 }, | ||
| 875 | { 0xcd036837, 0x130890a1, 0x36dba887, 482 }, | ||
| 876 | { 0x80222122, 0x6be55a64, 0xc2494954, 486 }, | ||
| 877 | { 0xa02aa96b, 0x06deb0fd, 0xf2db9baa, 489 }, | ||
| 878 | { 0xc83553c5, 0xc8965d3d, 0x6f928294, 492 }, | ||
| 879 | { 0xfa42a8b7, 0x3abbf48c, 0xcb772339, 495 }, | ||
| 880 | { 0x9c69a972, 0x84b578d7, 0xff2a7604, 499 }, | ||
| 881 | { 0xc38413cf, 0x25e2d70d, 0xfef51385, 502 }, | ||
| 882 | { 0xf46518c2, 0xef5b8cd1, 0x7eb25866, 505 }, | ||
| 883 | { 0x98bf2f79, 0xd5993802, 0xef2f773f, 509 }, | ||
| 884 | { 0xbeeefb58, 0x4aff8603, 0xaafb550f, 512 }, | ||
| 885 | { 0xeeaaba2e, 0x5dbf6784, 0x95ba2a53, 515 }, | ||
| 886 | { 0x952ab45c, 0xfa97a0b2, 0xdd945a74, 519 }, | ||
| 887 | { 0xba756174, 0x393d88df, 0x94f97111, 522 }, | ||
| 888 | { 0xe912b9d1, 0x478ceb17, 0x7a37cd56, 525 }, | ||
| 889 | { 0x91abb422, 0xccb812ee, 0xac62e055, 529 }, | ||
| 890 | { 0xb616a12b, 0x7fe617aa, 0x577b986b, 532 }, | ||
| 891 | { 0xe39c4976, 0x5fdf9d94, 0xed5a7e85, 535 }, | ||
| 892 | { 0x8e41ade9, 0xfbebc27d, 0x14588f13, 539 }, | ||
| 893 | { 0xb1d21964, 0x7ae6b31c, 0x596eb2d8, 542 }, | ||
| 894 | { 0xde469fbd, 0x99a05fe3, 0x6fca5f8e, 545 }, | ||
| 895 | { 0x8aec23d6, 0x80043bee, 0x25de7bb9, 549 }, | ||
| 896 | { 0xada72ccc, 0x20054ae9, 0xaf561aa7, 552 }, | ||
| 897 | { 0xd910f7ff, 0x28069da4, 0x1b2ba151, 555 }, | ||
| 898 | { 0x87aa9aff, 0x79042286, 0x90fb44d2, 559 }, | ||
| 899 | { 0xa99541bf, 0x57452b28, 0x353a1607, 562 }, | ||
| 900 | { 0xd3fa922f, 0x2d1675f2, 0x42889b89, 565 }, | ||
| 901 | { 0x847c9b5d, 0x7c2e09b7, 0x69956135, 569 }, | ||
| 902 | { 0xa59bc234, 0xdb398c25, 0x43fab983, 572 }, | ||
| 903 | { 0xcf02b2c2, 0x1207ef2e, 0x94f967e4, 575 }, | ||
| 904 | { 0x8161afb9, 0x4b44f57d, 0x1d1be0ee, 579 }, | ||
| 905 | { 0xa1ba1ba7, 0x9e1632dc, 0x6462d92a, 582 }, | ||
| 906 | { 0xca28a291, 0x859bbf93, 0x7d7b8f75, 585 }, | ||
| 907 | { 0xfcb2cb35, 0xe702af78, 0x5cda7352, 588 }, | ||
| 908 | { 0x9defbf01, 0xb061adab, 0x3a088813, 592 }, | ||
| 909 | { 0xc56baec2, 0x1c7a1916, 0x088aaa18, 595 }, | ||
| 910 | { 0xf6c69a72, 0xa3989f5b, 0x8aad549e, 598 }, | ||
| 911 | { 0x9a3c2087, 0xa63f6399, 0x36ac54e2, 602 }, | ||
| 912 | { 0xc0cb28a9, 0x8fcf3c7f, 0x84576a1b, 605 }, | ||
| 913 | { 0xf0fdf2d3, 0xf3c30b9f, 0x656d44a2, 608 }, | ||
| 914 | { 0x969eb7c4, 0x7859e743, 0x9f644ae5, 612 }, | ||
| 915 | { 0xbc4665b5, 0x96706114, 0x873d5d9f, 615 }, | ||
| 916 | { 0xeb57ff22, 0xfc0c7959, 0xa90cb506, 618 }, | ||
| 917 | { 0x9316ff75, 0xdd87cbd8, 0x09a7f124, 622 }, | ||
| 918 | { 0xb7dcbf53, 0x54e9bece, 0x0c11ed6d, 625 }, | ||
| 919 | { 0xe5d3ef28, 0x2a242e81, 0x8f1668c8, 628 }, | ||
| 920 | { 0x8fa47579, 0x1a569d10, 0xf96e017d, 632 }, | ||
| 921 | { 0xb38d92d7, 0x60ec4455, 0x37c981dc, 635 }, | ||
| 922 | { 0xe070f78d, 0x3927556a, 0x85bbe253, 638 }, | ||
| 923 | { 0x8c469ab8, 0x43b89562, 0x93956d74, 642 }, | ||
| 924 | { 0xaf584166, 0x54a6babb, 0x387ac8d1, 645 }, | ||
| 925 | { 0xdb2e51bf, 0xe9d0696a, 0x06997b05, 648 }, | ||
| 926 | { 0x88fcf317, 0xf22241e2, 0x441fece3, 652 }, | ||
| 927 | { 0xab3c2fdd, 0xeeaad25a, 0xd527e81c, 655 }, | ||
| 928 | { 0xd60b3bd5, 0x6a5586f1, 0x8a71e223, 658 }, | ||
| 929 | { 0x85c70565, 0x62757456, 0xf6872d56, 662 }, | ||
| 930 | { 0xa738c6be, 0xbb12d16c, 0xb428f8ac, 665 }, | ||
| 931 | { 0xd106f86e, 0x69d785c7, 0xe13336d7, 668 }, | ||
| 932 | { 0x82a45b45, 0x0226b39c, 0xecc00246, 672 }, | ||
| 933 | { 0xa34d7216, 0x42b06084, 0x27f002d7, 675 }, | ||
| 934 | { 0xcc20ce9b, 0xd35c78a5, 0x31ec038d, 678 }, | ||
| 935 | { 0xff290242, 0xc83396ce, 0x7e670471, 681 }, | ||
| 936 | { 0x9f79a169, 0xbd203e41, 0x0f0062c6, 685 }, | ||
| 937 | { 0xc75809c4, 0x2c684dd1, 0x52c07b78, 688 }, | ||
| 938 | { 0xf92e0c35, 0x37826145, 0xa7709a56, 691 }, | ||
| 939 | { 0x9bbcc7a1, 0x42b17ccb, 0x88a66076, 695 }, | ||
| 940 | { 0xc2abf989, 0x935ddbfe, 0x6acff893, 698 }, | ||
| 941 | { 0xf356f7eb, 0xf83552fe, 0x0583f6b8, 701 }, | ||
| 942 | { 0x98165af3, 0x7b2153de, 0xc3727a33, 705 }, | ||
| 943 | { 0xbe1bf1b0, 0x59e9a8d6, 0x744f18c0, 708 }, | ||
| 944 | { 0xeda2ee1c, 0x7064130c, 0x1162def0, 711 }, | ||
| 945 | { 0x9485d4d1, 0xc63e8be7, 0x8addcb56, 715 }, | ||
| 946 | { 0xb9a74a06, 0x37ce2ee1, 0x6d953e2b, 718 }, | ||
| 947 | { 0xe8111c87, 0xc5c1ba99, 0xc8fa8db6, 721 }, | ||
| 948 | { 0x910ab1d4, 0xdb9914a0, 0x1d9c9892, 725 }, | ||
| 949 | { 0xb54d5e4a, 0x127f59c8, 0x2503beb6, 728 }, | ||
| 950 | { 0xe2a0b5dc, 0x971f303a, 0x2e44ae64, 731 }, | ||
| 951 | { 0x8da471a9, 0xde737e24, 0x5ceaecfe, 735 }, | ||
| 952 | { 0xb10d8e14, 0x56105dad, 0x7425a83e, 738 }, | ||
| 953 | { 0xdd50f199, 0x6b947518, 0xd12f124e, 741 }, | ||
| 954 | { 0x8a5296ff, 0xe33cc92f, 0x82bd6b70, 745 }, | ||
| 955 | { 0xace73cbf, 0xdc0bfb7b, 0x636cc64d, 748 }, | ||
| 956 | { 0xd8210bef, 0xd30efa5a, 0x3c47f7e0, 751 }, | ||
| 957 | { 0x8714a775, 0xe3e95c78, 0x65acfaec, 755 }, | ||
| 958 | { 0xa8d9d153, 0x5ce3b396, 0x7f1839a7, 758 }, | ||
| 959 | { 0xd31045a8, 0x341ca07c, 0x1ede4811, 761 }, | ||
| 960 | { 0x83ea2b89, 0x2091e44d, 0x934aed0a, 765 }, | ||
| 961 | { 0xa4e4b66b, 0x68b65d60, 0xf81da84d, 768 }, | ||
| 962 | { 0xce1de406, 0x42e3f4b9, 0x36251260, 771 }, | ||
| 963 | { 0x80d2ae83, 0xe9ce78f3, 0xc1d72b7c, 775 }, | ||
| 964 | { 0xa1075a24, 0xe4421730, 0xb24cf65b, 778 }, | ||
| 965 | { 0xc94930ae, 0x1d529cfc, 0xdee033f2, 781 }, | ||
| 966 | { 0xfb9b7cd9, 0xa4a7443c, 0x169840ef, 784 }, | ||
| 967 | { 0x9d412e08, 0x06e88aa5, 0x8e1f2895, 788 }, | ||
| 968 | { 0xc491798a, 0x08a2ad4e, 0xf1a6f2ba, 791 }, | ||
| 969 | { 0xf5b5d7ec, 0x8acb58a2, 0xae10af69, 794 }, | ||
| 970 | { 0x9991a6f3, 0xd6bf1765, 0xacca6da1, 798 }, | ||
| 971 | { 0xbff610b0, 0xcc6edd3f, 0x17fd090a, 801 }, | ||
| 972 | { 0xeff394dc, 0xff8a948e, 0xddfc4b4c, 804 }, | ||
| 973 | { 0x95f83d0a, 0x1fb69cd9, 0x4abdaf10, 808 }, | ||
| 974 | { 0xbb764c4c, 0xa7a4440f, 0x9d6d1ad4, 811 }, | ||
| 975 | { 0xea53df5f, 0xd18d5513, 0x84c86189, 814 }, | ||
| 976 | { 0x92746b9b, 0xe2f8552c, 0x32fd3cf5, 818 }, | ||
| 977 | { 0xb7118682, 0xdbb66a77, 0x3fbc8c33, 821 }, | ||
| 978 | { 0xe4d5e823, 0x92a40515, 0x0fabaf3f, 824 }, | ||
| 979 | { 0x8f05b116, 0x3ba6832d, 0x29cb4d87, 828 }, | ||
| 980 | { 0xb2c71d5b, 0xca9023f8, 0x743e20e9, 831 }, | ||
| 981 | { 0xdf78e4b2, 0xbd342cf6, 0x914da924, 834 }, | ||
| 982 | { 0x8bab8eef, 0xb6409c1a, 0x1ad089b6, 838 }, | ||
| 983 | { 0xae9672ab, 0xa3d0c320, 0xa184ac24, 841 }, | ||
| 984 | { 0xda3c0f56, 0x8cc4f3e8, 0xc9e5d72d, 844 }, | ||
| 985 | { 0x88658996, 0x17fb1871, 0x7e2fa67c, 848 }, | ||
| 986 | { 0xaa7eebfb, 0x9df9de8d, 0xddbb901b, 851 }, | ||
| 987 | { 0xd51ea6fa, 0x85785631, 0x552a7422, 854 }, | ||
| 988 | { 0x8533285c, 0x936b35de, 0xd53a8895, 858 }, | ||
| 989 | { 0xa67ff273, 0xb8460356, 0x8a892aba, 861 }, | ||
| 990 | { 0xd01fef10, 0xa657842c, 0x2d2b7569, 864 }, | ||
| 991 | { 0x8213f56a, 0x67f6b29b, 0x9c3b2962, 868 }, | ||
| 992 | { 0xa298f2c5, 0x01f45f42, 0x8349f3ba, 871 }, | ||
| 993 | { 0xcb3f2f76, 0x42717713, 0x241c70a9, 874 }, | ||
| 994 | { 0xfe0efb53, 0xd30dd4d7, 0xed238cd3, 877 }, | ||
| 995 | { 0x9ec95d14, 0x63e8a506, 0xf4363804, 881 }, | ||
| 996 | { 0xc67bb459, 0x7ce2ce48, 0xb143c605, 884 }, | ||
| 997 | { 0xf81aa16f, 0xdc1b81da, 0xdd94b786, 887 }, | ||
| 998 | { 0x9b10a4e5, 0xe9913128, 0xca7cf2b4, 891 }, | ||
| 999 | { 0xc1d4ce1f, 0x63f57d72, 0xfd1c2f61, 894 }, | ||
| 1000 | { 0xf24a01a7, 0x3cf2dccf, 0xbc633b39, 897 }, | ||
| 1001 | { 0x976e4108, 0x8617ca01, 0xd5be0503, 901 }, | ||
| 1002 | { 0xbd49d14a, 0xa79dbc82, 0x4b2d8644, 904 }, | ||
| 1003 | { 0xec9c459d, 0x51852ba2, 0xddf8e7d6, 907 }, | ||
| 1004 | { 0x93e1ab82, 0x52f33b45, 0xcabb90e5, 911 }, | ||
| 1005 | { 0xb8da1662, 0xe7b00a17, 0x3d6a751f, 914 }, | ||
| 1006 | { 0xe7109bfb, 0xa19c0c9d, 0x0cc51267, 917 }, | ||
| 1007 | { 0x906a617d, 0x450187e2, 0x27fb2b80, 921 }, | ||
| 1008 | { 0xb484f9dc, 0x9641e9da, 0xb1f9f660, 924 }, | ||
| 1009 | { 0xe1a63853, 0xbbd26451, 0x5e7873f8, 927 }, | ||
| 1010 | { 0x8d07e334, 0x55637eb2, 0xdb0b487b, 931 }, | ||
| 1011 | { 0xb049dc01, 0x6abc5e5f, 0x91ce1a9a, 934 }, | ||
| 1012 | { 0xdc5c5301, 0xc56b75f7, 0x7641a140, 937 }, | ||
| 1013 | { 0x89b9b3e1, 0x1b6329ba, 0xa9e904c8, 941 }, | ||
| 1014 | { 0xac2820d9, 0x623bf429, 0x546345fa, 944 }, | ||
| 1015 | { 0xd732290f, 0xbacaf133, 0xa97c1779, 947 }, | ||
| 1016 | { 0x867f59a9, 0xd4bed6c0, 0x49ed8eab, 951 }, | ||
| 1017 | { 0xa81f3014, 0x49ee8c70, 0x5c68f256, 954 }, | ||
| 1018 | { 0xd226fc19, 0x5c6a2f8c, 0x73832eec, 957 }, | ||
| 1019 | { 0x83585d8f, 0xd9c25db7, 0xc831fd53, 961 }, | ||
| 1020 | { 0xa42e74f3, 0xd032f525, 0xba3e7ca8, 964 }, | ||
| 1021 | { 0xcd3a1230, 0xc43fb26f, 0x28ce1bd2, 967 }, | ||
| 1022 | { 0x80444b5e, 0x7aa7cf85, 0x7980d163, 971 }, | ||
| 1023 | { 0xa0555e36, 0x1951c366, 0xd7e105bc, 974 }, | ||
| 1024 | { 0xc86ab5c3, 0x9fa63440, 0x8dd9472b, 977 }, | ||
| 1025 | { 0xfa856334, 0x878fc150, 0xb14f98f6, 980 }, | ||
| 1026 | { 0x9c935e00, 0xd4b9d8d2, 0x6ed1bf9a, 984 }, | ||
| 1027 | { 0xc3b83581, 0x09e84f07, 0x0a862f80, 987 }, | ||
| 1028 | { 0xf4a642e1, 0x4c6262c8, 0xcd27bb61, 990 }, | ||
| 1029 | { 0x98e7e9cc, 0xcfbd7dbd, 0x8038d51c, 994 }, | ||
| 1030 | { 0xbf21e440, 0x03acdd2c, 0xe0470a63, 997 }, | ||
| 1031 | { 0xeeea5d50, 0x04981478, 0x1858ccfc, 1000 }, | ||
| 1032 | { 0x95527a52, 0x02df0ccb, 0x0f37801e, 1004 }, | ||
| 1033 | { 0xbaa718e6, 0x8396cffd, 0xd3056025, 1007 }, | ||
| 1034 | { 0xe950df20, 0x247c83fd, 0x47c6b82e, 1010 }, | ||
| 1035 | { 0x91d28b74, 0x16cdd27e, 0x4cdc331d, 1014 }, | ||
| 1036 | { 0xb6472e51, 0x1c81471d, 0xe0133fe4, 1017 }, | ||
| 1037 | { 0xe3d8f9e5, 0x63a198e5, 0x58180fdd, 1020 }, | ||
| 1038 | { 0x8e679c2f, 0x5e44ff8f, 0x570f09ea, 1024 }, | ||
| 1039 | { 0xb201833b, 0x35d63f73, 0x2cd2cc65, 1027 }, | ||
| 1040 | { 0xde81e40a, 0x034bcf4f, 0xf8077f7e, 1030 }, | ||
| 1041 | { 0x8b112e86, 0x420f6191, 0xfb04afaf, 1034 }, | ||
| 1042 | { 0xadd57a27, 0xd29339f6, 0x79c5db9a, 1037 }, | ||
| 1043 | { 0xd94ad8b1, 0xc7380874, 0x18375281, 1040 }, | ||
| 1044 | { 0x87cec76f, 0x1c830548, 0x8f229391, 1044 }, | ||
| 1045 | { 0xa9c2794a, 0xe3a3c69a, 0xb2eb3875, 1047 }, | ||
| 1046 | { 0xd433179d, 0x9c8cb841, 0x5fa60692, 1050 }, | ||
| 1047 | { 0x849feec2, 0x81d7f328, 0xdbc7c41b, 1054 }, | ||
| 1048 | { 0xa5c7ea73, 0x224deff3, 0x12b9b522, 1057 }, | ||
| 1049 | { 0xcf39e50f, 0xeae16bef, 0xd768226b, 1060 }, | ||
| 1050 | { 0x81842f29, 0xf2cce375, 0xe6a11583, 1064 }, | ||
| 1051 | { 0xa1e53af4, 0x6f801c53, 0x60495ae3, 1067 }, | ||
| 1052 | { 0xca5e89b1, 0x8b602368, 0x385bb19c, 1070 }, | ||
| 1053 | { 0xfcf62c1d, 0xee382c42, 0x46729e03, 1073 }, | ||
| 1054 | { 0x9e19db92, 0xb4e31ba9, 0x6c07a2c2, 1077 } | ||
| 1055 | }; | ||
| 1056 | static short int Lhint[2098] = { | ||
| 1057 | /*18,*/19, 19, 19, 19, 20, 20, 20, 21, 21, | ||
| 1058 | 21, 22, 22, 22, 23, 23, 23, 23, 24, 24, | ||
| 1059 | 24, 25, 25, 25, 26, 26, 26, 26, 27, 27, | ||
| 1060 | 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, | ||
| 1061 | 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, | ||
| 1062 | 33, 34, 34, 34, 35, 35, 35, 35, 36, 36, | ||
| 1063 | 36, 37, 37, 37, 38, 38, 38, 38, 39, 39, | ||
| 1064 | 39, 40, 40, 40, 41, 41, 41, 41, 42, 42, | ||
| 1065 | 42, 43, 43, 43, 44, 44, 44, 44, 45, 45, | ||
| 1066 | 45, 46, 46, 46, 47, 47, 47, 47, 48, 48, | ||
| 1067 | 48, 49, 49, 49, 50, 50, 50, 51, 51, 51, | ||
| 1068 | 51, 52, 52, 52, 53, 53, 53, 54, 54, 54, | ||
| 1069 | 54, 55, 55, 55, 56, 56, 56, 57, 57, 57, | ||
| 1070 | 57, 58, 58, 58, 59, 59, 59, 60, 60, 60, | ||
| 1071 | 60, 61, 61, 61, 62, 62, 62, 63, 63, 63, | ||
| 1072 | 63, 64, 64, 64, 65, 65, 65, 66, 66, 66, | ||
| 1073 | 66, 67, 67, 67, 68, 68, 68, 69, 69, 69, | ||
| 1074 | 69, 70, 70, 70, 71, 71, 71, 72, 72, 72, | ||
| 1075 | 72, 73, 73, 73, 74, 74, 74, 75, 75, 75, | ||
| 1076 | 75, 76, 76, 76, 77, 77, 77, 78, 78, 78, | ||
| 1077 | 78, 79, 79, 79, 80, 80, 80, 81, 81, 81, | ||
| 1078 | 82, 82, 82, 82, 83, 83, 83, 84, 84, 84, | ||
| 1079 | 85, 85, 85, 85, 86, 86, 86, 87, 87, 87, | ||
| 1080 | 88, 88, 88, 88, 89, 89, 89, 90, 90, 90, | ||
| 1081 | 91, 91, 91, 91, 92, 92, 92, 93, 93, 93, | ||
| 1082 | 94, 94, 94, 94, 95, 95, 95, 96, 96, 96, | ||
| 1083 | 97, 97, 97, 97, 98, 98, 98, 99, 99, 99, | ||
| 1084 | 100, 100, 100, 100, 101, 101, 101, 102, 102, 102, | ||
| 1085 | 103, 103, 103, 103, 104, 104, 104, 105, 105, 105, | ||
| 1086 | 106, 106, 106, 106, 107, 107, 107, 108, 108, 108, | ||
| 1087 | 109, 109, 109, 110, 110, 110, 110, 111, 111, 111, | ||
| 1088 | 112, 112, 112, 113, 113, 113, 113, 114, 114, 114, | ||
| 1089 | 115, 115, 115, 116, 116, 116, 116, 117, 117, 117, | ||
| 1090 | 118, 118, 118, 119, 119, 119, 119, 120, 120, 120, | ||
| 1091 | 121, 121, 121, 122, 122, 122, 122, 123, 123, 123, | ||
| 1092 | 124, 124, 124, 125, 125, 125, 125, 126, 126, 126, | ||
| 1093 | 127, 127, 127, 128, 128, 128, 128, 129, 129, 129, | ||
| 1094 | 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, | ||
| 1095 | 133, 133, 133, 134, 134, 134, 134, 135, 135, 135, | ||
| 1096 | 136, 136, 136, 137, 137, 137, 137, 138, 138, 138, | ||
| 1097 | 139, 139, 139, 140, 140, 140, 141, 141, 141, 141, | ||
| 1098 | 142, 142, 142, 143, 143, 143, 144, 144, 144, 144, | ||
| 1099 | 145, 145, 145, 146, 146, 146, 147, 147, 147, 147, | ||
| 1100 | 148, 148, 148, 149, 149, 149, 150, 150, 150, 150, | ||
| 1101 | 151, 151, 151, 152, 152, 152, 153, 153, 153, 153, | ||
| 1102 | 154, 154, 154, 155, 155, 155, 156, 156, 156, 156, | ||
| 1103 | 157, 157, 157, 158, 158, 158, 159, 159, 159, 159, | ||
| 1104 | 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, | ||
| 1105 | 163, 163, 163, 164, 164, 164, 165, 165, 165, 165, | ||
| 1106 | 166, 166, 166, 167, 167, 167, 168, 168, 168, 169, | ||
| 1107 | 169, 169, 169, 170, 170, 170, 171, 171, 171, 172, | ||
| 1108 | 172, 172, 172, 173, 173, 173, 174, 174, 174, 175, | ||
| 1109 | 175, 175, 175, 176, 176, 176, 177, 177, 177, 178, | ||
| 1110 | 178, 178, 178, 179, 179, 179, 180, 180, 180, 181, | ||
| 1111 | 181, 181, 181, 182, 182, 182, 183, 183, 183, 184, | ||
| 1112 | 184, 184, 184, 185, 185, 185, 186, 186, 186, 187, | ||
| 1113 | 187, 187, 187, 188, 188, 188, 189, 189, 189, 190, | ||
| 1114 | 190, 190, 190, 191, 191, 191, 192, 192, 192, 193, | ||
| 1115 | 193, 193, 193, 194, 194, 194, 195, 195, 195, 196, | ||
| 1116 | 196, 196, 197, 197, 197, 197, 198, 198, 198, 199, | ||
| 1117 | 199, 199, 200, 200, 200, 200, 201, 201, 201, 202, | ||
| 1118 | 202, 202, 203, 203, 203, 203, 204, 204, 204, 205, | ||
| 1119 | 205, 205, 206, 206, 206, 206, 207, 207, 207, 208, | ||
| 1120 | 208, 208, 209, 209, 209, 209, 210, 210, 210, 211, | ||
| 1121 | 211, 211, 212, 212, 212, 212, 213, 213, 213, 214, | ||
| 1122 | 214, 214, 215, 215, 215, 215, 216, 216, 216, 217, | ||
| 1123 | 217, 217, 218, 218, 218, 218, 219, 219, 219, 220, | ||
| 1124 | 220, 220, 221, 221, 221, 221, 222, 222, 222, 223, | ||
| 1125 | 223, 223, 224, 224, 224, 224, 225, 225, 225, 226, | ||
| 1126 | 226, 226, 227, 227, 227, 228, 228, 228, 228, 229, | ||
| 1127 | 229, 229, 230, 230, 230, 231, 231, 231, 231, 232, | ||
| 1128 | 232, 232, 233, 233, 233, 234, 234, 234, 234, 235, | ||
| 1129 | 235, 235, 236, 236, 236, 237, 237, 237, 237, 238, | ||
| 1130 | 238, 238, 239, 239, 239, 240, 240, 240, 240, 241, | ||
| 1131 | 241, 241, 242, 242, 242, 243, 243, 243, 243, 244, | ||
| 1132 | 244, 244, 245, 245, 245, 246, 246, 246, 246, 247, | ||
| 1133 | 247, 247, 248, 248, 248, 249, 249, 249, 249, 250, | ||
| 1134 | 250, 250, 251, 251, 251, 252, 252, 252, 252, 253, | ||
| 1135 | 253, 253, 254, 254, 254, 255, 255, 255, 256, 256, | ||
| 1136 | 256, 256, 257, 257, 257, 258, 258, 258, 259, 259, | ||
| 1137 | 259, 259, 260, 260, 260, 261, 261, 261, 262, 262, | ||
| 1138 | 262, 262, 263, 263, 263, 264, 264, 264, 265, 265, | ||
| 1139 | 265, 265, 266, 266, 266, 267, 267, 267, 268, 268, | ||
| 1140 | 268, 268, 269, 269, 269, 270, 270, 270, 271, 271, | ||
| 1141 | 271, 271, 272, 272, 272, 273, 273, 273, 274, 274, | ||
| 1142 | 274, 274, 275, 275, 275, 276, 276, 276, 277, 277, | ||
| 1143 | 277, 277, 278, 278, 278, 279, 279, 279, 280, 280, | ||
| 1144 | 280, 280, 281, 281, 281, 282, 282, 282, 283, 283, | ||
| 1145 | 283, 283, 284, 284, 284, 285, 285, 285, 286, 286, | ||
| 1146 | 286, 287, 287, 287, 287, 288, 288, 288, 289, 289, | ||
| 1147 | 289, 290, 290, 290, 290, 291, 291, 291, 292, 292, | ||
| 1148 | 292, 293, 293, 293, 293, 294, 294, 294, 295, 295, | ||
| 1149 | 295, 296, 296, 296, 296, 297, 297, 297, 298, 298, | ||
| 1150 | 298, 299, 299, 299, 299, 300, 300, 300, 301, 301, | ||
| 1151 | 301, 302, 302, 302, 302, 303, 303, 303, 304, 304, | ||
| 1152 | 304, 305, 305, 305, 305, 306, 306, 306, 307, 307, | ||
| 1153 | 307, 308, 308, 308, 308, 309, 309, 309, 310, 310, | ||
| 1154 | 310, 311, 311, 311, 311, 312, 312, 312, 313, 313, | ||
| 1155 | 313, 314, 314, 314, 315, 315, 315, 315, 316, 316, | ||
| 1156 | 316, 317, 317, 317, 318, 318, 318, 318, 319, 319, | ||
| 1157 | 319, 320, 320, 320, 321, 321, 321, 321, 322, 322, | ||
| 1158 | 322, 323, 323, 323, 324, 324, 324, 324, 325, 325, | ||
| 1159 | 325, 326, 326, 326, 327, 327, 327, 327, 328, 328, | ||
| 1160 | 328, 329, 329, 329, 330, 330, 330, 330, 331, 331, | ||
| 1161 | 331, 332, 332, 332, 333, 333, 333, 333, 334, 334, | ||
| 1162 | 334, 335, 335, 335, 336, 336, 336, 336, 337, 337, | ||
| 1163 | 337, 338, 338, 338, 339, 339, 339, 339, 340, 340, | ||
| 1164 | 340, 341, 341, 341, 342, 342, 342, 342, 343, 343, | ||
| 1165 | 343, 344, 344, 344, 345, 345, 345, 346, 346, 346, | ||
| 1166 | 346, 347, 347, 347, 348, 348, 348, 349, 349, 349, | ||
| 1167 | 349, 350, 350, 350, 351, 351, 351, 352, 352, 352, | ||
| 1168 | 352, 353, 353, 353, 354, 354, 354, 355, 355, 355, | ||
| 1169 | 355, 356, 356, 356, 357, 357, 357, 358, 358, 358, | ||
| 1170 | 358, 359, 359, 359, 360, 360, 360, 361, 361, 361, | ||
| 1171 | 361, 362, 362, 362, 363, 363, 363, 364, 364, 364, | ||
| 1172 | 364, 365, 365, 365, 366, 366, 366, 367, 367, 367, | ||
| 1173 | 367, 368, 368, 368, 369, 369, 369, 370, 370, 370, | ||
| 1174 | 370, 371, 371, 371, 372, 372, 372, 373, 373, 373, | ||
| 1175 | 374, 374, 374, 374, 375, 375, 375, 376, 376, 376, | ||
| 1176 | 377, 377, 377, 377, 378, 378, 378, 379, 379, 379, | ||
| 1177 | 380, 380, 380, 380, 381, 381, 381, 382, 382, 382, | ||
| 1178 | 383, 383, 383, 383, 384, 384, 384, 385, 385, 385, | ||
| 1179 | 386, 386, 386, 386, 387, 387, 387, 388, 388, 388, | ||
| 1180 | 389, 389, 389, 389, 390, 390, 390, 391, 391, 391, | ||
| 1181 | 392, 392, 392, 392, 393, 393, 393, 394, 394, 394, | ||
| 1182 | 395, 395, 395, 395, 396, 396, 396, 397, 397, 397, | ||
| 1183 | 398, 398, 398, 398, 399, 399, 399, 400, 400, 400, | ||
| 1184 | 401, 401, 401, 402, 402, 402, 402, 403, 403, 403, | ||
| 1185 | 404, 404, 404, 405, 405, 405, 405, 406, 406, 406, | ||
| 1186 | 407, 407, 407, 408, 408, 408, 408, 409, 409, 409, | ||
| 1187 | 410, 410, 410, 411, 411, 411, 411, 412, 412, 412, | ||
| 1188 | 413, 413, 413, 414, 414, 414, 414, 415, 415, 415, | ||
| 1189 | 416, 416, 416, 417, 417, 417, 417, 418, 418, 418, | ||
| 1190 | 419, 419, 419, 420, 420, 420, 420, 421, 421, 421, | ||
| 1191 | 422, 422, 422, 423, 423, 423, 423, 424, 424, 424, | ||
| 1192 | 425, 425, 425, 426, 426, 426, 426, 427, 427, 427, | ||
| 1193 | 428, 428, 428, 429, 429, 429, 429, 430, 430, 430, | ||
| 1194 | 431, 431, 431, 432, 432, 432, 433, 433, 433, 433, | ||
| 1195 | 434, 434, 434, 435, 435, 435, 436, 436, 436, 436, | ||
| 1196 | 437, 437, 437, 438, 438, 438, 439, 439, 439, 439, | ||
| 1197 | 440, 440, 440, 441, 441, 441, 442, 442, 442, 442, | ||
| 1198 | 443, 443, 443, 444, 444, 444, 445, 445, 445, 445, | ||
| 1199 | 446, 446, 446, 447, 447, 447, 448, 448, 448, 448, | ||
| 1200 | 449, 449, 449, 450, 450, 450, 451, 451, 451, 451, | ||
| 1201 | 452, 452, 452, 453, 453, 453, 454, 454, 454, 454, | ||
| 1202 | 455, 455, 455, 456, 456, 456, 457, 457, 457, 457, | ||
| 1203 | 458, 458, 458, 459, 459, 459, 460, 460, 460, 461, | ||
| 1204 | 461, 461, 461, 462, 462, 462, 463, 463, 463, 464, | ||
| 1205 | 464, 464, 464, 465, 465, 465, 466, 466, 466, 467, | ||
| 1206 | 467, 467, 467, 468, 468, 468, 469, 469, 469, 470, | ||
| 1207 | 470, 470, 470, 471, 471, 471, 472, 472, 472, 473, | ||
| 1208 | 473, 473, 473, 474, 474, 474, 475, 475, 475, 476, | ||
| 1209 | 476, 476, 476, 477, 477, 477, 478, 478, 478, 479, | ||
| 1210 | 479, 479, 479, 480, 480, 480, 481, 481, 481, 482, | ||
| 1211 | 482, 482, 482, 483, 483, 483, 484, 484, 484, 485, | ||
| 1212 | 485, 485, 485, 486, 486, 486, 487, 487, 487, 488, | ||
| 1213 | 488, 488, 488, 489, 489, 489, 490, 490, 490, 491, | ||
| 1214 | 491, 491, 492, 492, 492, 492, 493, 493, 493, 494, | ||
| 1215 | 494, 494, 495, 495, 495, 495, 496, 496, 496, 497, | ||
| 1216 | 497, 497, 498, 498, 498, 498, 499, 499, 499, 500, | ||
| 1217 | 500, 500, 501, 501, 501, 501, 502, 502, 502, 503, | ||
| 1218 | 503, 503, 504, 504, 504, 504, 505, 505, 505, 506, | ||
| 1219 | 506, 506, 507, 507, 507, 507, 508, 508, 508, 509, | ||
| 1220 | 509, 509, 510, 510, 510, 510, 511, 511, 511, 512, | ||
| 1221 | 512, 512, 513, 513, 513, 513, 514, 514, 514, 515, | ||
| 1222 | 515, 515, 516, 516, 516, 516, 517, 517, 517, 518, | ||
| 1223 | 518, 518, 519, 519, 519, 520, 520, 520, 520, 521, | ||
| 1224 | 521, 521, 522, 522, 522, 523, 523, 523, 523, 524, | ||
| 1225 | 524, 524, 525, 525, 525, 526, 526, 526, 526, 527, | ||
| 1226 | 527, 527, 528, 528, 528, 529, 529, 529, 529, 530, | ||
| 1227 | 530, 530, 531, 531, 531, 532, 532, 532, 532, 533, | ||
| 1228 | 533, 533, 534, 534, 534, 535, 535, 535, 535, 536, | ||
| 1229 | 536, 536, 537, 537, 537, 538, 538, 538, 538, 539, | ||
| 1230 | 539, 539, 540, 540, 540, 541, 541, 541, 541, 542, | ||
| 1231 | 542, 542, 543, 543, 543, 544, 544, 544, 544, 545, | ||
| 1232 | 545, 545, 546, 546, 546, 547, 547, 547, 548, 548, | ||
| 1233 | 548, 548, 549, 549, 549, 550, 550, 550, 551, 551, | ||
| 1234 | 551, 551, 552, 552, 552, 553, 553, 553, 554, 554, | ||
| 1235 | 554, 554, 555, 555, 555, 556, 556, 556, 557, 557, | ||
| 1236 | 557, 557, 558, 558, 558, 559, 559, 559, 560, 560, | ||
| 1237 | 560, 560, 561, 561, 561, 562, 562, 562, 563, 563, | ||
| 1238 | 563, 563, 564, 564, 564, 565, 565, 565, 566, 566, | ||
| 1239 | 566, 566, 567, 567, 567, 568, 568, 568, 569, 569, | ||
| 1240 | 569, 569, 570, 570, 570, 571, 571, 571, 572, 572, | ||
| 1241 | 572, 572, 573, 573, 573, 574, 574, 574, 575, 575, | ||
| 1242 | 575, 575, 576, 576, 576, 577, 577, 577, 578, 578, | ||
| 1243 | 578, 579, 579, 579, 579, 580, 580, 580, 581, 581, | ||
| 1244 | 581, 582, 582, 582, 582, 583, 583, 583, 584, 584, | ||
| 1245 | 584, 585, 585, 585, 585, 586, 586, 586, 587, 587, | ||
| 1246 | 587, 588, 588, 588, 588, 589, 589, 589, 590, 590, | ||
| 1247 | 590, 591, 591, 591, 591, 592, 592, 592, 593, 593, | ||
| 1248 | 593, 594, 594, 594, 594, 595, 595, 595, 596, 596, | ||
| 1249 | 596, 597, 597, 597, 597, 598, 598, 598, 599, 599, | ||
| 1250 | 599, 600, 600, 600, 600, 601, 601, 601, 602, 602, | ||
| 1251 | 602, 603, 603, 603, 603, 604, 604, 604, 605, 605, | ||
| 1252 | 605, 606, 606, 606, 607, 607, 607, 607, 608, 608, | ||
| 1253 | 608, 609, 609, 609, 610, 610, 610, 610, 611, 611, | ||
| 1254 | 611, 612, 612, 612, 613, 613, 613, 613, 614, 614, | ||
| 1255 | 614, 615, 615, 615, 616, 616, 616, 616, 617, 617, | ||
| 1256 | 617, 618, 618, 618, 619, 619, 619, 619, 620, 620, | ||
| 1257 | 620, 621, 621, 621, 622, 622, 622, 622, 623, 623, | ||
| 1258 | 623, 624, 624, 624, 625, 625, 625, 625, 626, 626, | ||
| 1259 | 626, 627, 627, 627, 628, 628, 628, 628, 629, 629, | ||
| 1260 | 629, 630, 630, 630, 631, 631, 631, 631, 632, 632, | ||
| 1261 | 632, 633, 633, 633, 634, 634, 634, 634, 635, 635, | ||
| 1262 | 635, 636, 636, 636, 637, 637, 637, 638, 638, 638, | ||
| 1263 | 638, 639, 639, 639, 640, 640, 640, 641, 641, 641, | ||
| 1264 | 641, 642, 642, 642, 643, 643, 643, 644, 644, 644, | ||
| 1265 | 644, 645, 645, 645, 646, 646, 646, 647, 647, 647, | ||
| 1266 | 647, 648, 648, 648, 649, 649, 649, 650, 650 }; | ||
| 1267 | static ULLong pfive[27] = { | ||
| 1268 | 5ll, | ||
| 1269 | 25ll, | ||
| 1270 | 125ll, | ||
| 1271 | 625ll, | ||
| 1272 | 3125ll, | ||
| 1273 | 15625ll, | ||
| 1274 | 78125ll, | ||
| 1275 | 390625ll, | ||
| 1276 | 1953125ll, | ||
| 1277 | 9765625ll, | ||
| 1278 | 48828125ll, | ||
| 1279 | 244140625ll, | ||
| 1280 | 1220703125ll, | ||
| 1281 | 6103515625ll, | ||
| 1282 | 30517578125ll, | ||
| 1283 | 152587890625ll, | ||
| 1284 | 762939453125ll, | ||
| 1285 | 3814697265625ll, | ||
| 1286 | 19073486328125ll, | ||
| 1287 | 95367431640625ll, | ||
| 1288 | 476837158203125ll, | ||
| 1289 | 2384185791015625ll, | ||
| 1290 | 11920928955078125ll, | ||
| 1291 | 59604644775390625ll, | ||
| 1292 | 298023223876953125ll, | ||
| 1293 | 1490116119384765625ll, | ||
| 1294 | 7450580596923828125ll | ||
| 1295 | }; | ||
| 1296 | |||
| 1297 | static int pfivebits[25] = {3, 5, 7, 10, 12, 14, 17, 19, 21, 24, 26, 28, 31, | ||
| 1298 | 33, 35, 38, 40, 42, 45, 47, 49, 52, 54, 56, 59}; | ||
| 1299 | #endif /*}*/ | ||
| 1300 | #endif /*}} NO_LONG_LONG */ | ||
| 1301 | |||
| 1302 | typedef union { double d; ULong L[2]; | ||
| 1303 | #ifdef USE_BF96 | ||
| 1304 | ULLong LL; | ||
| 1305 | #endif | ||
| 1306 | } U; | ||
| 308 | 1307 | ||
| 309 | #ifdef IEEE_8087 | 1308 | #ifdef IEEE_8087 |
| 310 | #define word0(x) (x)->L[1] | 1309 | #define word0(x) (x)->L[1] |
| @@ -314,6 +1313,7 @@ typedef union { double d; ULong L[2]; } U; | |||
| 314 | #define word1(x) (x)->L[1] | 1313 | #define word1(x) (x)->L[1] |
| 315 | #endif | 1314 | #endif |
| 316 | #define dval(x) (x)->d | 1315 | #define dval(x) (x)->d |
| 1316 | #define LLval(x) (x)->LL | ||
| 317 | 1317 | ||
| 318 | #ifndef STRTOD_DIGLIM | 1318 | #ifndef STRTOD_DIGLIM |
| 319 | #define STRTOD_DIGLIM 40 | 1319 | #define STRTOD_DIGLIM 40 |
| @@ -471,11 +1471,7 @@ extern int strtod_diglim; | |||
| 471 | #ifdef RND_PRODQUOT | 1471 | #ifdef RND_PRODQUOT |
| 472 | #define rounded_product(a,b) a = rnd_prod(a, b) | 1472 | #define rounded_product(a,b) a = rnd_prod(a, b) |
| 473 | #define rounded_quotient(a,b) a = rnd_quot(a, b) | 1473 | #define rounded_quotient(a,b) a = rnd_quot(a, b) |
| 474 | #ifdef KR_headers | ||
| 475 | extern double rnd_prod(), rnd_quot(); | ||
| 476 | #else | ||
| 477 | extern double rnd_prod(double, double), rnd_quot(double, double); | 1474 | extern double rnd_prod(double, double), rnd_quot(double, double); |
| 478 | #endif | ||
| 479 | #else | 1475 | #else |
| 480 | #define rounded_product(a,b) a *= b | 1476 | #define rounded_product(a,b) a *= b |
| 481 | #define rounded_quotient(a,b) a /= b | 1477 | #define rounded_quotient(a,b) a /= b |
| @@ -492,34 +1488,17 @@ typedef struct BCinfo BCinfo; | |||
| 492 | struct | 1488 | struct |
| 493 | BCinfo { int dp0, dp1, dplen, dsign, e0, inexact, nd, nd0, rounding, scale, uflchk; }; | 1489 | BCinfo { int dp0, dp1, dplen, dsign, e0, inexact, nd, nd0, rounding, scale, uflchk; }; |
| 494 | 1490 | ||
| 495 | #ifdef KR_headers | ||
| 496 | #define FFFFFFFF ((((unsigned long)0xffff)<<16)|(unsigned long)0xffff) | ||
| 497 | #else | ||
| 498 | #define FFFFFFFF 0xffffffffUL | 1491 | #define FFFFFFFF 0xffffffffUL |
| 499 | #endif | ||
| 500 | |||
| 501 | #ifdef NO_LONG_LONG | ||
| 502 | #undef ULLong | ||
| 503 | #ifdef Just_16 | ||
| 504 | #undef Pack_32 | ||
| 505 | /* When Pack_32 is not defined, we store 16 bits per 32-bit Long. | ||
| 506 | * This makes some inner loops simpler and sometimes saves work | ||
| 507 | * during multiplications, but it often seems to make things slightly | ||
| 508 | * slower. Hence the default is now to store 32 bits per Long. | ||
| 509 | */ | ||
| 510 | #endif | ||
| 511 | #else /* long long available */ | ||
| 512 | #ifndef Llong | ||
| 513 | #define Llong long long | ||
| 514 | #endif | ||
| 515 | #ifndef ULLong | ||
| 516 | #define ULLong unsigned Llong | ||
| 517 | #endif | ||
| 518 | #endif /* NO_LONG_LONG */ | ||
| 519 | 1492 | ||
| 520 | #ifndef MULTIPLE_THREADS | 1493 | #ifdef MULTIPLE_THREADS |
| 521 | #define ACQUIRE_DTOA_LOCK(n) /*nothing*/ | 1494 | #define MTa , PTI |
| 522 | #define FREE_DTOA_LOCK(n) /*nothing*/ | 1495 | #define MTb , &TI |
| 1496 | #define MTd , ThInfo **PTI | ||
| 1497 | static unsigned int maxthreads = 0; | ||
| 1498 | #else | ||
| 1499 | #define MTa /*nothing*/ | ||
| 1500 | #define MTb /*nothing*/ | ||
| 1501 | #define MTd /*nothing*/ | ||
| 523 | #endif | 1502 | #endif |
| 524 | 1503 | ||
| 525 | #define Kmax 7 | 1504 | #define Kmax 7 |
| @@ -538,24 +1517,77 @@ Bigint { | |||
| 538 | }; | 1517 | }; |
| 539 | 1518 | ||
| 540 | typedef struct Bigint Bigint; | 1519 | typedef struct Bigint Bigint; |
| 1520 | typedef struct | ||
| 1521 | ThInfo { | ||
| 1522 | Bigint *Freelist[Kmax+1]; | ||
| 1523 | Bigint *P5s; | ||
| 1524 | } ThInfo; | ||
| 541 | 1525 | ||
| 542 | static Bigint *freelist[Kmax+1]; | 1526 | static ThInfo TI0; |
| 543 | 1527 | ||
| 544 | static Bigint * | 1528 | #ifdef MULTIPLE_THREADS |
| 545 | Balloc | 1529 | static ThInfo *TI1; |
| 546 | #ifdef KR_headers | 1530 | static int TI0_used; |
| 547 | (k) int k; | 1531 | |
| 1532 | void | ||
| 1533 | set_max_dtoa_threads(unsigned int n) | ||
| 1534 | { | ||
| 1535 | size_t L; | ||
| 1536 | |||
| 1537 | if (n > maxthreads) { | ||
| 1538 | L = n*sizeof(ThInfo); | ||
| 1539 | if (TI1) { | ||
| 1540 | TI1 = (ThInfo*)REALLOC(TI1, L); | ||
| 1541 | memset(TI1 + maxthreads, 0, (n-maxthreads)*sizeof(ThInfo)); | ||
| 1542 | } | ||
| 1543 | else { | ||
| 1544 | TI1 = (ThInfo*)MALLOC(L); | ||
| 1545 | if (TI0_used) { | ||
| 1546 | memcpy(TI1, &TI0, sizeof(ThInfo)); | ||
| 1547 | if (n > 1) | ||
| 1548 | memset(TI1 + 1, 0, L - sizeof(ThInfo)); | ||
| 1549 | memset(&TI0, 0, sizeof(ThInfo)); | ||
| 1550 | } | ||
| 1551 | else | ||
| 1552 | memset(TI1, 0, L); | ||
| 1553 | } | ||
| 1554 | maxthreads = n; | ||
| 1555 | } | ||
| 1556 | } | ||
| 1557 | |||
| 1558 | static ThInfo* | ||
| 1559 | get_TI(void) | ||
| 1560 | { | ||
| 1561 | unsigned int thno = dtoa_get_threadno(); | ||
| 1562 | if (thno < maxthreads) | ||
| 1563 | return TI1 + thno; | ||
| 1564 | if (thno == 0) | ||
| 1565 | TI0_used = 1; | ||
| 1566 | return &TI0; | ||
| 1567 | } | ||
| 1568 | #define freelist TI->Freelist | ||
| 1569 | #define p5s TI->P5s | ||
| 548 | #else | 1570 | #else |
| 549 | (int k) | 1571 | #define freelist TI0.Freelist |
| 1572 | #define p5s TI0.P5s | ||
| 550 | #endif | 1573 | #endif |
| 1574 | |||
| 1575 | static Bigint * | ||
| 1576 | Balloc(int k MTd) | ||
| 551 | { | 1577 | { |
| 552 | int x; | 1578 | int x; |
| 553 | Bigint *rv; | 1579 | Bigint *rv; |
| 554 | #ifndef Omit_Private_Memory | 1580 | #ifndef Omit_Private_Memory |
| 555 | unsigned int len; | 1581 | unsigned int len; |
| 556 | #endif | 1582 | #endif |
| 1583 | #ifdef MULTIPLE_THREADS | ||
| 1584 | ThInfo *TI; | ||
| 557 | 1585 | ||
| 558 | ACQUIRE_DTOA_LOCK(0); | 1586 | if (!(TI = *PTI)) |
| 1587 | *PTI = TI = get_TI(); | ||
| 1588 | if (TI == &TI0) | ||
| 1589 | ACQUIRE_DTOA_LOCK(0); | ||
| 1590 | #endif | ||
| 559 | /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */ | 1591 | /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */ |
| 560 | /* but this case seems very unlikely. */ | 1592 | /* but this case seems very unlikely. */ |
| 561 | if (k <= Kmax && (rv = freelist[k])) | 1593 | if (k <= Kmax && (rv = freelist[k])) |
| @@ -567,7 +1599,11 @@ Balloc | |||
| 567 | #else | 1599 | #else |
| 568 | len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) | 1600 | len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) |
| 569 | /sizeof(double); | 1601 | /sizeof(double); |
| 570 | if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) { | 1602 | if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem |
| 1603 | #ifdef MULTIPLE_THREADS | ||
| 1604 | && TI == TI1 | ||
| 1605 | #endif | ||
| 1606 | ) { | ||
| 571 | rv = (Bigint*)pmem_next; | 1607 | rv = (Bigint*)pmem_next; |
| 572 | pmem_next += len; | 1608 | pmem_next += len; |
| 573 | } | 1609 | } |
| @@ -577,31 +1613,36 @@ Balloc | |||
| 577 | rv->k = k; | 1613 | rv->k = k; |
| 578 | rv->maxwds = x; | 1614 | rv->maxwds = x; |
| 579 | } | 1615 | } |
| 580 | FREE_DTOA_LOCK(0); | 1616 | #ifdef MULTIPLE_THREADS |
| 1617 | if (TI == &TI0) | ||
| 1618 | FREE_DTOA_LOCK(0); | ||
| 1619 | #endif | ||
| 581 | rv->sign = rv->wds = 0; | 1620 | rv->sign = rv->wds = 0; |
| 582 | return rv; | 1621 | return rv; |
| 583 | } | 1622 | } |
| 584 | 1623 | ||
| 585 | static void | 1624 | static void |
| 586 | Bfree | 1625 | Bfree(Bigint *v MTd) |
| 587 | #ifdef KR_headers | ||
| 588 | (v) Bigint *v; | ||
| 589 | #else | ||
| 590 | (Bigint *v) | ||
| 591 | #endif | ||
| 592 | { | 1626 | { |
| 1627 | #ifdef MULTIPLE_THREADS | ||
| 1628 | ThInfo *TI; | ||
| 1629 | #endif | ||
| 593 | if (v) { | 1630 | if (v) { |
| 594 | if (v->k > Kmax) | 1631 | if (v->k > Kmax) |
| 595 | #ifdef FREE | ||
| 596 | FREE((void*)v); | 1632 | FREE((void*)v); |
| 597 | #else | ||
| 598 | free((void*)v); | ||
| 599 | #endif | ||
| 600 | else { | 1633 | else { |
| 601 | ACQUIRE_DTOA_LOCK(0); | 1634 | #ifdef MULTIPLE_THREADS |
| 1635 | if (!(TI = *PTI)) | ||
| 1636 | *PTI = TI = get_TI(); | ||
| 1637 | if (TI == &TI0) | ||
| 1638 | ACQUIRE_DTOA_LOCK(0); | ||
| 1639 | #endif | ||
| 602 | v->next = freelist[v->k]; | 1640 | v->next = freelist[v->k]; |
| 603 | freelist[v->k] = v; | 1641 | freelist[v->k] = v; |
| 604 | FREE_DTOA_LOCK(0); | 1642 | #ifdef MULTIPLE_THREADS |
| 1643 | if (TI == &TI0) | ||
| 1644 | FREE_DTOA_LOCK(0); | ||
| 1645 | #endif | ||
| 605 | } | 1646 | } |
| 606 | } | 1647 | } |
| 607 | } | 1648 | } |
| @@ -610,12 +1651,7 @@ Bfree | |||
| 610 | y->wds*sizeof(Long) + 2*sizeof(int)) | 1651 | y->wds*sizeof(Long) + 2*sizeof(int)) |
| 611 | 1652 | ||
| 612 | static Bigint * | 1653 | static Bigint * |
| 613 | multadd | 1654 | multadd(Bigint *b, int m, int a MTd) /* multiply by m and add a */ |
| 614 | #ifdef KR_headers | ||
| 615 | (b, m, a) Bigint *b; int m, a; | ||
| 616 | #else | ||
| 617 | (Bigint *b, int m, int a) /* multiply by m and add a */ | ||
| 618 | #endif | ||
| 619 | { | 1655 | { |
| 620 | int i, wds; | 1656 | int i, wds; |
| 621 | #ifdef ULLong | 1657 | #ifdef ULLong |
| @@ -655,9 +1691,9 @@ multadd | |||
| 655 | while(++i < wds); | 1691 | while(++i < wds); |
| 656 | if (carry) { | 1692 | if (carry) { |
| 657 | if (wds >= b->maxwds) { | 1693 | if (wds >= b->maxwds) { |
| 658 | b1 = Balloc(b->k+1); | 1694 | b1 = Balloc(b->k+1 MTa); |
| 659 | Bcopy(b1, b); | 1695 | Bcopy(b1, b); |
| 660 | Bfree(b); | 1696 | Bfree(b MTa); |
| 661 | b = b1; | 1697 | b = b1; |
| 662 | } | 1698 | } |
| 663 | b->x[wds++] = carry; | 1699 | b->x[wds++] = carry; |
| @@ -667,12 +1703,7 @@ multadd | |||
| 667 | } | 1703 | } |
| 668 | 1704 | ||
| 669 | static Bigint * | 1705 | static Bigint * |
| 670 | s2b | 1706 | s2b(const char *s, int nd0, int nd, ULong y9, int dplen MTd) |
| 671 | #ifdef KR_headers | ||
| 672 | (s, nd0, nd, y9, dplen) CONST char *s; int nd0, nd, dplen; ULong y9; | ||
| 673 | #else | ||
| 674 | (const char *s, int nd0, int nd, ULong y9, int dplen) | ||
| 675 | #endif | ||
| 676 | { | 1707 | { |
| 677 | Bigint *b; | 1708 | Bigint *b; |
| 678 | int i, k; | 1709 | int i, k; |
| @@ -681,11 +1712,11 @@ s2b | |||
| 681 | x = (nd + 8) / 9; | 1712 | x = (nd + 8) / 9; |
| 682 | for(k = 0, y = 1; x > y; y <<= 1, k++) ; | 1713 | for(k = 0, y = 1; x > y; y <<= 1, k++) ; |
| 683 | #ifdef Pack_32 | 1714 | #ifdef Pack_32 |
| 684 | b = Balloc(k); | 1715 | b = Balloc(k MTa); |
| 685 | b->x[0] = y9; | 1716 | b->x[0] = y9; |
| 686 | b->wds = 1; | 1717 | b->wds = 1; |
| 687 | #else | 1718 | #else |
| 688 | b = Balloc(k+1); | 1719 | b = Balloc(k+1 MTa); |
| 689 | b->x[0] = y9 & 0xffff; | 1720 | b->x[0] = y9 & 0xffff; |
| 690 | b->wds = (b->x[1] = y9 >> 16) ? 2 : 1; | 1721 | b->wds = (b->x[1] = y9 >> 16) ? 2 : 1; |
| 691 | #endif | 1722 | #endif |
| @@ -693,24 +1724,19 @@ s2b | |||
| 693 | i = 9; | 1724 | i = 9; |
| 694 | if (9 < nd0) { | 1725 | if (9 < nd0) { |
| 695 | s += 9; | 1726 | s += 9; |
| 696 | do b = multadd(b, 10, *s++ - '0'); | 1727 | do b = multadd(b, 10, *s++ - '0' MTa); |
| 697 | while(++i < nd0); | 1728 | while(++i < nd0); |
| 698 | s += dplen; | 1729 | s += dplen; |
| 699 | } | 1730 | } |
| 700 | else | 1731 | else |
| 701 | s += dplen + 9; | 1732 | s += dplen + 9; |
| 702 | for(; i < nd; i++) | 1733 | for(; i < nd; i++) |
| 703 | b = multadd(b, 10, *s++ - '0'); | 1734 | b = multadd(b, 10, *s++ - '0' MTa); |
| 704 | return b; | 1735 | return b; |
| 705 | } | 1736 | } |
| 706 | 1737 | ||
| 707 | static int | 1738 | static int |
| 708 | hi0bits | 1739 | hi0bits(ULong x) |
| 709 | #ifdef KR_headers | ||
| 710 | (x) ULong x; | ||
| 711 | #else | ||
| 712 | (ULong x) | ||
| 713 | #endif | ||
| 714 | { | 1740 | { |
| 715 | int k = 0; | 1741 | int k = 0; |
| 716 | 1742 | ||
| @@ -739,12 +1765,7 @@ hi0bits | |||
| 739 | } | 1765 | } |
| 740 | 1766 | ||
| 741 | static int | 1767 | static int |
| 742 | lo0bits | 1768 | lo0bits(ULong *y) |
| 743 | #ifdef KR_headers | ||
| 744 | (y) ULong *y; | ||
| 745 | #else | ||
| 746 | (ULong *y) | ||
| 747 | #endif | ||
| 748 | { | 1769 | { |
| 749 | int k; | 1770 | int k; |
| 750 | ULong x = *y; | 1771 | ULong x = *y; |
| @@ -787,28 +1808,18 @@ lo0bits | |||
| 787 | } | 1808 | } |
| 788 | 1809 | ||
| 789 | static Bigint * | 1810 | static Bigint * |
| 790 | i2b | 1811 | i2b(int i MTd) |
| 791 | #ifdef KR_headers | ||
| 792 | (i) int i; | ||
| 793 | #else | ||
| 794 | (int i) | ||
| 795 | #endif | ||
| 796 | { | 1812 | { |
| 797 | Bigint *b; | 1813 | Bigint *b; |
| 798 | 1814 | ||
| 799 | b = Balloc(1); | 1815 | b = Balloc(1 MTa); |
| 800 | b->x[0] = i; | 1816 | b->x[0] = i; |
| 801 | b->wds = 1; | 1817 | b->wds = 1; |
| 802 | return b; | 1818 | return b; |
| 803 | } | 1819 | } |
| 804 | 1820 | ||
| 805 | static Bigint * | 1821 | static Bigint * |
| 806 | mult | 1822 | mult(Bigint *a, Bigint *b MTd) |
| 807 | #ifdef KR_headers | ||
| 808 | (a, b) Bigint *a, *b; | ||
| 809 | #else | ||
| 810 | (Bigint *a, Bigint *b) | ||
| 811 | #endif | ||
| 812 | { | 1823 | { |
| 813 | Bigint *c; | 1824 | Bigint *c; |
| 814 | int k, wa, wb, wc; | 1825 | int k, wa, wb, wc; |
| @@ -834,7 +1845,7 @@ mult | |||
| 834 | wc = wa + wb; | 1845 | wc = wa + wb; |
| 835 | if (wc > a->maxwds) | 1846 | if (wc > a->maxwds) |
| 836 | k++; | 1847 | k++; |
| 837 | c = Balloc(k); | 1848 | c = Balloc(k MTa); |
| 838 | for(x = c->x, xa = x + wc; x < xa; x++) | 1849 | for(x = c->x, xa = x + wc; x < xa; x++) |
| 839 | *x = 0; | 1850 | *x = 0; |
| 840 | xa = a->x; | 1851 | xa = a->x; |
| @@ -912,55 +1923,63 @@ mult | |||
| 912 | return c; | 1923 | return c; |
| 913 | } | 1924 | } |
| 914 | 1925 | ||
| 915 | static Bigint *p5s; | ||
| 916 | |||
| 917 | static Bigint * | 1926 | static Bigint * |
| 918 | pow5mult | 1927 | pow5mult(Bigint *b, int k MTd) |
| 919 | #ifdef KR_headers | ||
| 920 | (b, k) Bigint *b; int k; | ||
| 921 | #else | ||
| 922 | (Bigint *b, int k) | ||
| 923 | #endif | ||
| 924 | { | 1928 | { |
| 925 | Bigint *b1, *p5, *p51; | 1929 | Bigint *b1, *p5, *p51; |
| 1930 | #ifdef MULTIPLE_THREADS | ||
| 1931 | ThInfo *TI; | ||
| 1932 | #endif | ||
| 926 | int i; | 1933 | int i; |
| 927 | static int p05[3] = { 5, 25, 125 }; | 1934 | static int p05[3] = { 5, 25, 125 }; |
| 928 | 1935 | ||
| 929 | if ((i = k & 3)) | 1936 | if ((i = k & 3)) |
| 930 | b = multadd(b, p05[i-1], 0); | 1937 | b = multadd(b, p05[i-1], 0 MTa); |
| 931 | 1938 | ||
| 932 | if (!(k >>= 2)) | 1939 | if (!(k >>= 2)) |
| 933 | return b; | 1940 | return b; |
| 1941 | #ifdef MULTIPLE_THREADS | ||
| 1942 | if (!(TI = *PTI)) | ||
| 1943 | *PTI = TI = get_TI(); | ||
| 1944 | #endif | ||
| 934 | if (!(p5 = p5s)) { | 1945 | if (!(p5 = p5s)) { |
| 935 | /* first time */ | 1946 | /* first time */ |
| 936 | #ifdef MULTIPLE_THREADS | 1947 | #ifdef MULTIPLE_THREADS |
| 937 | ACQUIRE_DTOA_LOCK(1); | 1948 | if (!(TI = *PTI)) |
| 1949 | *PTI = TI = get_TI(); | ||
| 1950 | if (TI == &TI0) | ||
| 1951 | ACQUIRE_DTOA_LOCK(1); | ||
| 938 | if (!(p5 = p5s)) { | 1952 | if (!(p5 = p5s)) { |
| 939 | p5 = p5s = i2b(625); | 1953 | p5 = p5s = i2b(625 MTa); |
| 940 | p5->next = 0; | 1954 | p5->next = 0; |
| 941 | } | 1955 | } |
| 942 | FREE_DTOA_LOCK(1); | 1956 | if (TI == &TI0) |
| 1957 | FREE_DTOA_LOCK(1); | ||
| 943 | #else | 1958 | #else |
| 944 | p5 = p5s = i2b(625); | 1959 | p5 = p5s = i2b(625 MTa); |
| 945 | p5->next = 0; | 1960 | p5->next = 0; |
| 946 | #endif | 1961 | #endif |
| 947 | } | 1962 | } |
| 948 | for(;;) { | 1963 | for(;;) { |
| 949 | if (k & 1) { | 1964 | if (k & 1) { |
| 950 | b1 = mult(b, p5); | 1965 | b1 = mult(b, p5 MTa); |
| 951 | Bfree(b); | 1966 | Bfree(b MTa); |
| 952 | b = b1; | 1967 | b = b1; |
| 953 | } | 1968 | } |
| 954 | if (!(k >>= 1)) | 1969 | if (!(k >>= 1)) |
| 955 | break; | 1970 | break; |
| 956 | if (!(p51 = p5->next)) { | 1971 | if (!(p51 = p5->next)) { |
| 957 | #ifdef MULTIPLE_THREADS | 1972 | #ifdef MULTIPLE_THREADS |
| 958 | ACQUIRE_DTOA_LOCK(1); | 1973 | if (!TI && !(TI = *PTI)) |
| 1974 | *PTI = TI = get_TI(); | ||
| 1975 | if (TI == &TI0) | ||
| 1976 | ACQUIRE_DTOA_LOCK(1); | ||
| 959 | if (!(p51 = p5->next)) { | 1977 | if (!(p51 = p5->next)) { |
| 960 | p51 = p5->next = mult(p5,p5); | 1978 | p51 = p5->next = mult(p5,p5 MTa); |
| 961 | p51->next = 0; | 1979 | p51->next = 0; |
| 962 | } | 1980 | } |
| 963 | FREE_DTOA_LOCK(1); | 1981 | if (TI == &TI0) |
| 1982 | FREE_DTOA_LOCK(1); | ||
| 964 | #else | 1983 | #else |
| 965 | p51 = p5->next = mult(p5,p5); | 1984 | p51 = p5->next = mult(p5,p5); |
| 966 | p51->next = 0; | 1985 | p51->next = 0; |
| @@ -972,12 +1991,7 @@ pow5mult | |||
| 972 | } | 1991 | } |
| 973 | 1992 | ||
| 974 | static Bigint * | 1993 | static Bigint * |
| 975 | lshift | 1994 | lshift(Bigint *b, int k MTd) |
| 976 | #ifdef KR_headers | ||
| 977 | (b, k) Bigint *b; int k; | ||
| 978 | #else | ||
| 979 | (Bigint *b, int k) | ||
| 980 | #endif | ||
| 981 | { | 1995 | { |
| 982 | int i, k1, n, n1; | 1996 | int i, k1, n, n1; |
| 983 | Bigint *b1; | 1997 | Bigint *b1; |
| @@ -992,7 +2006,7 @@ lshift | |||
| 992 | n1 = n + b->wds + 1; | 2006 | n1 = n + b->wds + 1; |
| 993 | for(i = b->maxwds; n1 > i; i <<= 1) | 2007 | for(i = b->maxwds; n1 > i; i <<= 1) |
| 994 | k1++; | 2008 | k1++; |
| 995 | b1 = Balloc(k1); | 2009 | b1 = Balloc(k1 MTa); |
| 996 | x1 = b1->x; | 2010 | x1 = b1->x; |
| 997 | for(i = 0; i < n; i++) | 2011 | for(i = 0; i < n; i++) |
| 998 | *x1++ = 0; | 2012 | *x1++ = 0; |
| @@ -1027,17 +2041,12 @@ lshift | |||
| 1027 | *x1++ = *x++; | 2041 | *x1++ = *x++; |
| 1028 | while(x < xe); | 2042 | while(x < xe); |
| 1029 | b1->wds = n1 - 1; | 2043 | b1->wds = n1 - 1; |
| 1030 | Bfree(b); | 2044 | Bfree(b MTa); |
| 1031 | return b1; | 2045 | return b1; |
| 1032 | } | 2046 | } |
| 1033 | 2047 | ||
| 1034 | static int | 2048 | static int |
| 1035 | cmp | 2049 | cmp(Bigint *a, Bigint *b) |
| 1036 | #ifdef KR_headers | ||
| 1037 | (a, b) Bigint *a, *b; | ||
| 1038 | #else | ||
| 1039 | (Bigint *a, Bigint *b) | ||
| 1040 | #endif | ||
| 1041 | { | 2050 | { |
| 1042 | ULong *xa, *xa0, *xb, *xb0; | 2051 | ULong *xa, *xa0, *xb, *xb0; |
| 1043 | int i, j; | 2052 | int i, j; |
| @@ -1066,12 +2075,7 @@ cmp | |||
| 1066 | } | 2075 | } |
| 1067 | 2076 | ||
| 1068 | static Bigint * | 2077 | static Bigint * |
| 1069 | diff | 2078 | diff(Bigint *a, Bigint *b MTd) |
| 1070 | #ifdef KR_headers | ||
| 1071 | (a, b) Bigint *a, *b; | ||
| 1072 | #else | ||
| 1073 | (Bigint *a, Bigint *b) | ||
| 1074 | #endif | ||
| 1075 | { | 2079 | { |
| 1076 | Bigint *c; | 2080 | Bigint *c; |
| 1077 | int i, wa, wb; | 2081 | int i, wa, wb; |
| @@ -1087,7 +2091,7 @@ diff | |||
| 1087 | 2091 | ||
| 1088 | i = cmp(a,b); | 2092 | i = cmp(a,b); |
| 1089 | if (!i) { | 2093 | if (!i) { |
| 1090 | c = Balloc(0); | 2094 | c = Balloc(0 MTa); |
| 1091 | c->wds = 1; | 2095 | c->wds = 1; |
| 1092 | c->x[0] = 0; | 2096 | c->x[0] = 0; |
| 1093 | return c; | 2097 | return c; |
| @@ -1100,7 +2104,7 @@ diff | |||
| 1100 | } | 2104 | } |
| 1101 | else | 2105 | else |
| 1102 | i = 0; | 2106 | i = 0; |
| 1103 | c = Balloc(a->k); | 2107 | c = Balloc(a->k MTa); |
| 1104 | c->sign = i; | 2108 | c->sign = i; |
| 1105 | wa = a->wds; | 2109 | wa = a->wds; |
| 1106 | xa = a->x; | 2110 | xa = a->x; |
| @@ -1160,12 +2164,7 @@ diff | |||
| 1160 | } | 2164 | } |
| 1161 | 2165 | ||
| 1162 | static double | 2166 | static double |
| 1163 | ulp | 2167 | ulp(U *x) |
| 1164 | #ifdef KR_headers | ||
| 1165 | (x) U *x; | ||
| 1166 | #else | ||
| 1167 | (U *x) | ||
| 1168 | #endif | ||
| 1169 | { | 2168 | { |
| 1170 | Long L; | 2169 | Long L; |
| 1171 | U u; | 2170 | U u; |
| @@ -1202,12 +2201,7 @@ ulp | |||
| 1202 | } | 2201 | } |
| 1203 | 2202 | ||
| 1204 | static double | 2203 | static double |
| 1205 | b2d | 2204 | b2d(Bigint *a, int *e) |
| 1206 | #ifdef KR_headers | ||
| 1207 | (a, e) Bigint *a; int *e; | ||
| 1208 | #else | ||
| 1209 | (Bigint *a, int *e) | ||
| 1210 | #endif | ||
| 1211 | { | 2205 | { |
| 1212 | ULong *xa, *xa0, w, y, z; | 2206 | ULong *xa, *xa0, w, y, z; |
| 1213 | int k; | 2207 | int k; |
| @@ -1272,12 +2266,7 @@ b2d | |||
| 1272 | } | 2266 | } |
| 1273 | 2267 | ||
| 1274 | static Bigint * | 2268 | static Bigint * |
| 1275 | d2b | 2269 | d2b(U *d, int *e, int *bits MTd) |
| 1276 | #ifdef KR_headers | ||
| 1277 | (d, e, bits) U *d; int *e, *bits; | ||
| 1278 | #else | ||
| 1279 | (U *d, int *e, int *bits) | ||
| 1280 | #endif | ||
| 1281 | { | 2270 | { |
| 1282 | Bigint *b; | 2271 | Bigint *b; |
| 1283 | int de, k; | 2272 | int de, k; |
| @@ -1295,9 +2284,9 @@ d2b | |||
| 1295 | #endif | 2284 | #endif |
| 1296 | 2285 | ||
| 1297 | #ifdef Pack_32 | 2286 | #ifdef Pack_32 |
| 1298 | b = Balloc(1); | 2287 | b = Balloc(1 MTa); |
| 1299 | #else | 2288 | #else |
| 1300 | b = Balloc(2); | 2289 | b = Balloc(2 MTa); |
| 1301 | #endif | 2290 | #endif |
| 1302 | x = b->x; | 2291 | x = b->x; |
| 1303 | 2292 | ||
| @@ -1406,12 +2395,7 @@ d2b | |||
| 1406 | #undef d1 | 2395 | #undef d1 |
| 1407 | 2396 | ||
| 1408 | static double | 2397 | static double |
| 1409 | ratio | 2398 | ratio(Bigint *a, Bigint *b) |
| 1410 | #ifdef KR_headers | ||
| 1411 | (a, b) Bigint *a, *b; | ||
| 1412 | #else | ||
| 1413 | (Bigint *a, Bigint *b) | ||
| 1414 | #endif | ||
| 1415 | { | 2399 | { |
| 1416 | U da, db; | 2400 | U da, db; |
| 1417 | int k, ka, kb; | 2401 | int k, ka, kb; |
| @@ -1446,7 +2430,7 @@ ratio | |||
| 1446 | return dval(&da) / dval(&db); | 2430 | return dval(&da) / dval(&db); |
| 1447 | } | 2431 | } |
| 1448 | 2432 | ||
| 1449 | static CONST double | 2433 | static const double |
| 1450 | tens[] = { | 2434 | tens[] = { |
| 1451 | 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, | 2435 | 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, |
| 1452 | 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, | 2436 | 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, |
| @@ -1456,10 +2440,10 @@ tens[] = { | |||
| 1456 | #endif | 2440 | #endif |
| 1457 | }; | 2441 | }; |
| 1458 | 2442 | ||
| 1459 | static CONST double | 2443 | static const double |
| 1460 | #ifdef IEEE_Arith | 2444 | #ifdef IEEE_Arith |
| 1461 | bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; | 2445 | bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; |
| 1462 | static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, | 2446 | static const double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, |
| 1463 | #ifdef Avoid_Underflow | 2447 | #ifdef Avoid_Underflow |
| 1464 | 9007199254740992.*9007199254740992.e-256 | 2448 | 9007199254740992.*9007199254740992.e-256 |
| 1465 | /* = 2^106 * 1e-256 */ | 2449 | /* = 2^106 * 1e-256 */ |
| @@ -1474,11 +2458,11 @@ static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, | |||
| 1474 | #else | 2458 | #else |
| 1475 | #ifdef IBM | 2459 | #ifdef IBM |
| 1476 | bigtens[] = { 1e16, 1e32, 1e64 }; | 2460 | bigtens[] = { 1e16, 1e32, 1e64 }; |
| 1477 | static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 }; | 2461 | static const double tinytens[] = { 1e-16, 1e-32, 1e-64 }; |
| 1478 | #define n_bigtens 3 | 2462 | #define n_bigtens 3 |
| 1479 | #else | 2463 | #else |
| 1480 | bigtens[] = { 1e16, 1e32 }; | 2464 | bigtens[] = { 1e16, 1e32 }; |
| 1481 | static CONST double tinytens[] = { 1e-16, 1e-32 }; | 2465 | static const double tinytens[] = { 1e-16, 1e-32 }; |
| 1482 | #define n_bigtens 2 | 2466 | #define n_bigtens 2 |
| 1483 | #endif | 2467 | #endif |
| 1484 | #endif | 2468 | #endif |
| @@ -1497,14 +2481,11 @@ static CONST double tinytens[] = { 1e-16, 1e-32 }; | |||
| 1497 | #endif | 2481 | #endif |
| 1498 | 2482 | ||
| 1499 | #ifdef Need_Hexdig /*{*/ | 2483 | #ifdef Need_Hexdig /*{*/ |
| 2484 | #if 0 | ||
| 1500 | static unsigned char hexdig[256]; | 2485 | static unsigned char hexdig[256]; |
| 1501 | 2486 | ||
| 1502 | static void | 2487 | static void |
| 1503 | #ifdef KR_headers | ||
| 1504 | htinit(h, s, inc) unsigned char *h; unsigned char *s; int inc; | ||
| 1505 | #else | ||
| 1506 | htinit(unsigned char *h, unsigned char *s, int inc) | 2488 | htinit(unsigned char *h, unsigned char *s, int inc) |
| 1507 | #endif | ||
| 1508 | { | 2489 | { |
| 1509 | int i, j; | 2490 | int i, j; |
| 1510 | for(i = 0; (j = s[i]) !=0; i++) | 2491 | for(i = 0; (j = s[i]) !=0; i++) |
| @@ -1512,17 +2493,34 @@ htinit(unsigned char *h, unsigned char *s, int inc) | |||
| 1512 | } | 2493 | } |
| 1513 | 2494 | ||
| 1514 | static void | 2495 | static void |
| 1515 | #ifdef KR_headers | 2496 | hexdig_init(void) /* Use of hexdig_init omitted 20121220 to avoid a */ |
| 1516 | hexdig_init() | 2497 | /* race condition when multiple threads are used. */ |
| 1517 | #else | ||
| 1518 | hexdig_init(void) | ||
| 1519 | #endif | ||
| 1520 | { | 2498 | { |
| 1521 | #define USC (unsigned char *) | 2499 | #define USC (unsigned char *) |
| 1522 | htinit(hexdig, USC "0123456789", 0x10); | 2500 | htinit(hexdig, USC "0123456789", 0x10); |
| 1523 | htinit(hexdig, USC "abcdef", 0x10 + 10); | 2501 | htinit(hexdig, USC "abcdef", 0x10 + 10); |
| 1524 | htinit(hexdig, USC "ABCDEF", 0x10 + 10); | 2502 | htinit(hexdig, USC "ABCDEF", 0x10 + 10); |
| 1525 | } | 2503 | } |
| 2504 | #else | ||
| 2505 | static unsigned char hexdig[256] = { | ||
| 2506 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2507 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2508 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2509 | 16,17,18,19,20,21,22,23,24,25,0,0,0,0,0,0, | ||
| 2510 | 0,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0, | ||
| 2511 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2512 | 0,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0, | ||
| 2513 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2514 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2515 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2516 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2517 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2518 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2519 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2520 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | ||
| 2521 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 | ||
| 2522 | }; | ||
| 2523 | #endif | ||
| 1526 | #endif /* } Need_Hexdig */ | 2524 | #endif /* } Need_Hexdig */ |
| 1527 | 2525 | ||
| 1528 | #ifdef INFNAN_CHECK | 2526 | #ifdef INFNAN_CHECK |
| @@ -1536,15 +2534,10 @@ hexdig_init(void) | |||
| 1536 | #endif | 2534 | #endif |
| 1537 | 2535 | ||
| 1538 | static int | 2536 | static int |
| 1539 | match | 2537 | match(const char **sp, const char *t) |
| 1540 | #ifdef KR_headers | ||
| 1541 | (sp, t) char **sp, *t; | ||
| 1542 | #else | ||
| 1543 | (const char **sp, const char *t) | ||
| 1544 | #endif | ||
| 1545 | { | 2538 | { |
| 1546 | int c, d; | 2539 | int c, d; |
| 1547 | CONST char *s = *sp; | 2540 | const char *s = *sp; |
| 1548 | 2541 | ||
| 1549 | while((d = *t++)) { | 2542 | while((d = *t++)) { |
| 1550 | if ((c = *++s) >= 'A' && c <= 'Z') | 2543 | if ((c = *++s) >= 'A' && c <= 'Z') |
| @@ -1558,29 +2551,23 @@ match | |||
| 1558 | 2551 | ||
| 1559 | #ifndef No_Hex_NaN | 2552 | #ifndef No_Hex_NaN |
| 1560 | static void | 2553 | static void |
| 1561 | hexnan | 2554 | hexnan(U *rvp, const char **sp) |
| 1562 | #ifdef KR_headers | ||
| 1563 | (rvp, sp) U *rvp; CONST char **sp; | ||
| 1564 | #else | ||
| 1565 | (U *rvp, const char **sp) | ||
| 1566 | #endif | ||
| 1567 | { | 2555 | { |
| 1568 | ULong c, x[2]; | 2556 | ULong c, x[2]; |
| 1569 | CONST char *s; | 2557 | const char *s; |
| 1570 | int c1, havedig, udx0, xshift; | 2558 | int c1, havedig, udx0, xshift; |
| 1571 | 2559 | ||
| 1572 | if (!hexdig['0']) | 2560 | /**** if (!hexdig['0']) hexdig_init(); ****/ |
| 1573 | hexdig_init(); | ||
| 1574 | x[0] = x[1] = 0; | 2561 | x[0] = x[1] = 0; |
| 1575 | havedig = xshift = 0; | 2562 | havedig = xshift = 0; |
| 1576 | udx0 = 1; | 2563 | udx0 = 1; |
| 1577 | s = *sp; | 2564 | s = *sp; |
| 1578 | /* allow optional initial 0x or 0X */ | 2565 | /* allow optional initial 0x or 0X */ |
| 1579 | while((c = *(CONST unsigned char*)(s+1)) && c <= ' ') | 2566 | while((c = *(const unsigned char*)(s+1)) && c <= ' ') |
| 1580 | ++s; | 2567 | ++s; |
| 1581 | if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X')) | 2568 | if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X')) |
| 1582 | s += 2; | 2569 | s += 2; |
| 1583 | while((c = *(CONST unsigned char*)++s)) { | 2570 | while((c = *(const unsigned char*)++s)) { |
| 1584 | if ((c1 = hexdig[c])) | 2571 | if ((c1 = hexdig[c])) |
| 1585 | c = c1 & 0xf; | 2572 | c = c1 & 0xf; |
| 1586 | else if (c <= ' ') { | 2573 | else if (c <= ' ') { |
| @@ -1638,11 +2625,7 @@ hexnan | |||
| 1638 | 2625 | ||
| 1639 | #if !defined(NO_HEX_FP) || defined(Honor_FLT_ROUNDS) /*{*/ | 2626 | #if !defined(NO_HEX_FP) || defined(Honor_FLT_ROUNDS) /*{*/ |
| 1640 | static Bigint * | 2627 | static Bigint * |
| 1641 | #ifdef KR_headers | 2628 | increment(Bigint *b MTd) |
| 1642 | increment(b) Bigint *b; | ||
| 1643 | #else | ||
| 1644 | increment(Bigint *b) | ||
| 1645 | #endif | ||
| 1646 | { | 2629 | { |
| 1647 | ULong *x, *xe; | 2630 | ULong *x, *xe; |
| 1648 | Bigint *b1; | 2631 | Bigint *b1; |
| @@ -1658,9 +2641,9 @@ increment(Bigint *b) | |||
| 1658 | } while(x < xe); | 2641 | } while(x < xe); |
| 1659 | { | 2642 | { |
| 1660 | if (b->wds >= b->maxwds) { | 2643 | if (b->wds >= b->maxwds) { |
| 1661 | b1 = Balloc(b->k+1); | 2644 | b1 = Balloc(b->k+1 MTa); |
| 1662 | Bcopy(b1,b); | 2645 | Bcopy(b1,b); |
| 1663 | Bfree(b); | 2646 | Bfree(b MTa); |
| 1664 | b = b1; | 2647 | b = b1; |
| 1665 | } | 2648 | } |
| 1666 | b->x[b->wds++] = 1; | 2649 | b->x[b->wds++] = 1; |
| @@ -1673,11 +2656,7 @@ increment(Bigint *b) | |||
| 1673 | #ifndef NO_HEX_FP /*{*/ | 2656 | #ifndef NO_HEX_FP /*{*/ |
| 1674 | 2657 | ||
| 1675 | static void | 2658 | static void |
| 1676 | #ifdef KR_headers | ||
| 1677 | rshift(b, k) Bigint *b; int k; | ||
| 1678 | #else | ||
| 1679 | rshift(Bigint *b, int k) | 2659 | rshift(Bigint *b, int k) |
| 1680 | #endif | ||
| 1681 | { | 2660 | { |
| 1682 | ULong *x, *x1, *xe, y; | 2661 | ULong *x, *x1, *xe, y; |
| 1683 | int n; | 2662 | int n; |
| @@ -1706,11 +2685,7 @@ rshift(Bigint *b, int k) | |||
| 1706 | } | 2685 | } |
| 1707 | 2686 | ||
| 1708 | static ULong | 2687 | static ULong |
| 1709 | #ifdef KR_headers | ||
| 1710 | any_on(b, k) Bigint *b; int k; | ||
| 1711 | #else | ||
| 1712 | any_on(Bigint *b, int k) | 2688 | any_on(Bigint *b, int k) |
| 1713 | #endif | ||
| 1714 | { | 2689 | { |
| 1715 | int n, nwds; | 2690 | int n, nwds; |
| 1716 | ULong *x, *x0, x1, x2; | 2691 | ULong *x, *x0, x1, x2; |
| @@ -1743,15 +2718,10 @@ enum { /* rounding values: same as FLT_ROUNDS */ | |||
| 1743 | }; | 2718 | }; |
| 1744 | 2719 | ||
| 1745 | void | 2720 | void |
| 1746 | #ifdef KR_headers | 2721 | gethex( const char **sp, U *rvp, int rounding, int sign MTd) |
| 1747 | gethex(sp, rvp, rounding, sign) | ||
| 1748 | CONST char **sp; U *rvp; int rounding, sign; | ||
| 1749 | #else | ||
| 1750 | gethex( CONST char **sp, U *rvp, int rounding, int sign) | ||
| 1751 | #endif | ||
| 1752 | { | 2722 | { |
| 1753 | Bigint *b; | 2723 | Bigint *b; |
| 1754 | CONST unsigned char *decpt, *s0, *s, *s1; | 2724 | const unsigned char *decpt, *s0, *s, *s1; |
| 1755 | Long e, e1; | 2725 | Long e, e1; |
| 1756 | ULong L, lostbits, *x; | 2726 | ULong L, lostbits, *x; |
| 1757 | int big, denorm, esign, havedig, k, n, nbits, up, zret; | 2727 | int big, denorm, esign, havedig, k, n, nbits, up, zret; |
| @@ -1783,8 +2753,8 @@ gethex( CONST char **sp, U *rvp, int rounding, int sign) | |||
| 1783 | if (!(s0 = decimalpoint_cache)) { | 2753 | if (!(s0 = decimalpoint_cache)) { |
| 1784 | s0 = (unsigned char*)localeconv()->decimal_point; | 2754 | s0 = (unsigned char*)localeconv()->decimal_point; |
| 1785 | if ((decimalpoint_cache = (unsigned char*) | 2755 | if ((decimalpoint_cache = (unsigned char*) |
| 1786 | MALLOC(strlen((CONST char*)s0) + 1))) { | 2756 | MALLOC(strlen((const char*)s0) + 1))) { |
| 1787 | strcpy((char*)decimalpoint_cache, (CONST char*)s0); | 2757 | strcpy((char*)decimalpoint_cache, (const char*)s0); |
| 1788 | s0 = decimalpoint_cache; | 2758 | s0 = decimalpoint_cache; |
| 1789 | } | 2759 | } |
| 1790 | } | 2760 | } |
| @@ -1792,10 +2762,9 @@ gethex( CONST char **sp, U *rvp, int rounding, int sign) | |||
| 1792 | #endif | 2762 | #endif |
| 1793 | #endif | 2763 | #endif |
| 1794 | 2764 | ||
| 1795 | if (!hexdig['0']) | 2765 | /**** if (!hexdig['0']) hexdig_init(); ****/ |
| 1796 | hexdig_init(); | ||
| 1797 | havedig = 0; | 2766 | havedig = 0; |
| 1798 | s0 = *(CONST unsigned char **)sp + 2; | 2767 | s0 = *(const unsigned char **)sp + 2; |
| 1799 | while(s0[havedig] == '0') | 2768 | while(s0[havedig] == '0') |
| 1800 | havedig++; | 2769 | havedig++; |
| 1801 | s0 += havedig; | 2770 | s0 += havedig; |
| @@ -1893,10 +2862,10 @@ gethex( CONST char **sp, U *rvp, int rounding, int sign) | |||
| 1893 | #endif | 2862 | #endif |
| 1894 | goto retz; | 2863 | goto retz; |
| 1895 | #ifdef IEEE_Arith | 2864 | #ifdef IEEE_Arith |
| 2865 | ret_tinyf: | ||
| 2866 | Bfree(b MTa); | ||
| 1896 | ret_tiny: | 2867 | ret_tiny: |
| 1897 | #ifndef NO_ERRNO | 2868 | Set_errno(ERANGE); |
| 1898 | errno = ERANGE; | ||
| 1899 | #endif | ||
| 1900 | word0(rvp) = 0; | 2869 | word0(rvp) = 0; |
| 1901 | word1(rvp) = 1; | 2870 | word1(rvp) = 1; |
| 1902 | return; | 2871 | return; |
| @@ -1922,7 +2891,7 @@ gethex( CONST char **sp, U *rvp, int rounding, int sign) | |||
| 1922 | n = s1 - s0 - 1; | 2891 | n = s1 - s0 - 1; |
| 1923 | for(k = 0; n > (1 << (kshift-2)) - 1; n >>= 1) | 2892 | for(k = 0; n > (1 << (kshift-2)) - 1; n >>= 1) |
| 1924 | k++; | 2893 | k++; |
| 1925 | b = Balloc(k); | 2894 | b = Balloc(k MTa); |
| 1926 | x = b->x; | 2895 | x = b->x; |
| 1927 | n = 0; | 2896 | n = 0; |
| 1928 | L = 0; | 2897 | L = 0; |
| @@ -1969,16 +2938,27 @@ gethex( CONST char **sp, U *rvp, int rounding, int sign) | |||
| 1969 | } | 2938 | } |
| 1970 | else if (n < nbits) { | 2939 | else if (n < nbits) { |
| 1971 | n = nbits - n; | 2940 | n = nbits - n; |
| 1972 | b = lshift(b, n); | 2941 | b = lshift(b, n MTa); |
| 1973 | e -= n; | 2942 | e -= n; |
| 1974 | x = b->x; | 2943 | x = b->x; |
| 1975 | } | 2944 | } |
| 1976 | if (e > Emax) { | 2945 | if (e > emax) { |
| 1977 | ovfl: | 2946 | ovfl: |
| 1978 | Bfree(b); | 2947 | Bfree(b MTa); |
| 1979 | ovfl1: | 2948 | ovfl1: |
| 1980 | #ifndef NO_ERRNO | 2949 | Set_errno(ERANGE); |
| 1981 | errno = ERANGE; | 2950 | #ifdef Honor_FLT_ROUNDS |
| 2951 | switch (rounding) { | ||
| 2952 | case Round_zero: | ||
| 2953 | goto ret_big; | ||
| 2954 | case Round_down: | ||
| 2955 | if (!sign) | ||
| 2956 | goto ret_big; | ||
| 2957 | break; | ||
| 2958 | case Round_up: | ||
| 2959 | if (sign) | ||
| 2960 | goto ret_big; | ||
| 2961 | } | ||
| 1982 | #endif | 2962 | #endif |
| 1983 | word0(rvp) = Exp_mask; | 2963 | word0(rvp) = Exp_mask; |
| 1984 | word1(rvp) = 0; | 2964 | word1(rvp) = 0; |
| @@ -1992,23 +2972,21 @@ gethex( CONST char **sp, U *rvp, int rounding, int sign) | |||
| 1992 | #ifdef IEEE_Arith /*{*/ | 2972 | #ifdef IEEE_Arith /*{*/ |
| 1993 | switch (rounding) { | 2973 | switch (rounding) { |
| 1994 | case Round_near: | 2974 | case Round_near: |
| 1995 | if (n == nbits && (n < 2 || any_on(b,n-1))) | 2975 | if (n == nbits && (n < 2 || lostbits || any_on(b,n-1))) |
| 1996 | goto ret_tiny; | 2976 | goto ret_tinyf; |
| 1997 | break; | 2977 | break; |
| 1998 | case Round_up: | 2978 | case Round_up: |
| 1999 | if (!sign) | 2979 | if (!sign) |
| 2000 | goto ret_tiny; | 2980 | goto ret_tinyf; |
| 2001 | break; | 2981 | break; |
| 2002 | case Round_down: | 2982 | case Round_down: |
| 2003 | if (sign) | 2983 | if (sign) |
| 2004 | goto ret_tiny; | 2984 | goto ret_tinyf; |
| 2005 | } | 2985 | } |
| 2006 | #endif /* } IEEE_Arith */ | 2986 | #endif /* } IEEE_Arith */ |
| 2007 | Bfree(b); | 2987 | Bfree(b MTa); |
| 2008 | retz: | 2988 | retz: |
| 2009 | #ifndef NO_ERRNO | 2989 | Set_errno(ERANGE); |
| 2010 | errno = ERANGE; | ||
| 2011 | #endif | ||
| 2012 | retz1: | 2990 | retz1: |
| 2013 | rvp->d = 0.; | 2991 | rvp->d = 0.; |
| 2014 | return; | 2992 | return; |
| @@ -2042,7 +3020,7 @@ gethex( CONST char **sp, U *rvp, int rounding, int sign) | |||
| 2042 | } | 3020 | } |
| 2043 | if (up) { | 3021 | if (up) { |
| 2044 | k = b->wds; | 3022 | k = b->wds; |
| 2045 | b = increment(b); | 3023 | b = increment(b MTa); |
| 2046 | x = b->x; | 3024 | x = b->x; |
| 2047 | if (denorm) { | 3025 | if (denorm) { |
| 2048 | #if 0 | 3026 | #if 0 |
| @@ -2099,16 +3077,12 @@ gethex( CONST char **sp, U *rvp, int rounding, int sign) | |||
| 2099 | word0(rvp) = ((b->x[1] & ~0x800000) >> 16) | ((e + 129 + 55) << 7) | (b->x[1] << 16); | 3077 | word0(rvp) = ((b->x[1] & ~0x800000) >> 16) | ((e + 129 + 55) << 7) | (b->x[1] << 16); |
| 2100 | word1(rvp) = (b->x[0] >> 16) | (b->x[0] << 16); | 3078 | word1(rvp) = (b->x[0] >> 16) | (b->x[0] << 16); |
| 2101 | #endif | 3079 | #endif |
| 2102 | Bfree(b); | 3080 | Bfree(b MTa); |
| 2103 | } | 3081 | } |
| 2104 | #endif /*!NO_HEX_FP}*/ | 3082 | #endif /*!NO_HEX_FP}*/ |
| 2105 | 3083 | ||
| 2106 | static int | 3084 | static int |
| 2107 | #ifdef KR_headers | ||
| 2108 | dshift(b, p2) Bigint *b; int p2; | ||
| 2109 | #else | ||
| 2110 | dshift(Bigint *b, int p2) | 3085 | dshift(Bigint *b, int p2) |
| 2111 | #endif | ||
| 2112 | { | 3086 | { |
| 2113 | int rv = hi0bits(b->x[b->wds-1]) - 4; | 3087 | int rv = hi0bits(b->x[b->wds-1]) - 4; |
| 2114 | if (p2 > 0) | 3088 | if (p2 > 0) |
| @@ -2117,12 +3091,7 @@ dshift(Bigint *b, int p2) | |||
| 2117 | } | 3091 | } |
| 2118 | 3092 | ||
| 2119 | static int | 3093 | static int |
| 2120 | quorem | 3094 | quorem(Bigint *b, Bigint *S) |
| 2121 | #ifdef KR_headers | ||
| 2122 | (b, S) Bigint *b, *S; | ||
| 2123 | #else | ||
| 2124 | (Bigint *b, Bigint *S) | ||
| 2125 | #endif | ||
| 2126 | { | 3095 | { |
| 2127 | int n; | 3096 | int n; |
| 2128 | ULong *bx, *bxe, q, *sx, *sxe; | 3097 | ULong *bx, *bxe, q, *sx, *sxe; |
| @@ -2242,12 +3211,7 @@ quorem | |||
| 2242 | 3211 | ||
| 2243 | #if defined(Avoid_Underflow) || !defined(NO_STRTOD_BIGCOMP) /*{*/ | 3212 | #if defined(Avoid_Underflow) || !defined(NO_STRTOD_BIGCOMP) /*{*/ |
| 2244 | static double | 3213 | static double |
| 2245 | sulp | 3214 | sulp(U *x, BCinfo *bc) |
| 2246 | #ifdef KR_headers | ||
| 2247 | (x, bc) U *x; BCinfo *bc; | ||
| 2248 | #else | ||
| 2249 | (U *x, BCinfo *bc) | ||
| 2250 | #endif | ||
| 2251 | { | 3215 | { |
| 2252 | U u; | 3216 | U u; |
| 2253 | double rv; | 3217 | double rv; |
| @@ -2264,13 +3228,7 @@ sulp | |||
| 2264 | 3228 | ||
| 2265 | #ifndef NO_STRTOD_BIGCOMP | 3229 | #ifndef NO_STRTOD_BIGCOMP |
| 2266 | static void | 3230 | static void |
| 2267 | bigcomp | 3231 | bigcomp(U *rv, const char *s0, BCinfo *bc MTd) |
| 2268 | #ifdef KR_headers | ||
| 2269 | (rv, s0, bc) | ||
| 2270 | U *rv; CONST char *s0; BCinfo *bc; | ||
| 2271 | #else | ||
| 2272 | (U *rv, const char *s0, BCinfo *bc) | ||
| 2273 | #endif | ||
| 2274 | { | 3232 | { |
| 2275 | Bigint *b, *d; | 3233 | Bigint *b, *d; |
| 2276 | int b2, bbits, d2, dd, dig, dsign, i, j, nd, nd0, p2, p5, speccase; | 3234 | int b2, bbits, d2, dd, dig, dsign, i, j, nd, nd0, p2, p5, speccase; |
| @@ -2283,7 +3241,7 @@ bigcomp | |||
| 2283 | #ifndef Sudden_Underflow | 3241 | #ifndef Sudden_Underflow |
| 2284 | if (rv->d == 0.) { /* special case: value near underflow-to-zero */ | 3242 | if (rv->d == 0.) { /* special case: value near underflow-to-zero */ |
| 2285 | /* threshold was rounded to zero */ | 3243 | /* threshold was rounded to zero */ |
| 2286 | b = i2b(1); | 3244 | b = i2b(1 MTa); |
| 2287 | p2 = Emin - P + 1; | 3245 | p2 = Emin - P + 1; |
| 2288 | bbits = 1; | 3246 | bbits = 1; |
| 2289 | #ifdef Avoid_Underflow | 3247 | #ifdef Avoid_Underflow |
| @@ -2304,7 +3262,7 @@ bigcomp | |||
| 2304 | } | 3262 | } |
| 2305 | else | 3263 | else |
| 2306 | #endif | 3264 | #endif |
| 2307 | b = d2b(rv, &p2, &bbits); | 3265 | b = d2b(rv, &p2, &bbits MTa); |
| 2308 | #ifdef Avoid_Underflow | 3266 | #ifdef Avoid_Underflow |
| 2309 | p2 -= bc->scale; | 3267 | p2 -= bc->scale; |
| 2310 | #endif | 3268 | #endif |
| @@ -2313,8 +3271,8 @@ bigcomp | |||
| 2313 | i = P - bbits; | 3271 | i = P - bbits; |
| 2314 | if (i > (j = P - Emin - 1 + p2)) { | 3272 | if (i > (j = P - Emin - 1 + p2)) { |
| 2315 | #ifdef Sudden_Underflow | 3273 | #ifdef Sudden_Underflow |
| 2316 | Bfree(b); | 3274 | Bfree(b MTa); |
| 2317 | b = i2b(1); | 3275 | b = i2b(1 MTa); |
| 2318 | p2 = Emin; | 3276 | p2 = Emin; |
| 2319 | i = P - 1; | 3277 | i = P - 1; |
| 2320 | #ifdef Avoid_Underflow | 3278 | #ifdef Avoid_Underflow |
| @@ -2330,28 +3288,28 @@ bigcomp | |||
| 2330 | #ifdef Honor_FLT_ROUNDS | 3288 | #ifdef Honor_FLT_ROUNDS |
| 2331 | if (bc->rounding != 1) { | 3289 | if (bc->rounding != 1) { |
| 2332 | if (i > 0) | 3290 | if (i > 0) |
| 2333 | b = lshift(b, i); | 3291 | b = lshift(b, i MTa); |
| 2334 | if (dsign) | 3292 | if (dsign) |
| 2335 | b = increment(b); | 3293 | b = increment(b MTa); |
| 2336 | } | 3294 | } |
| 2337 | else | 3295 | else |
| 2338 | #endif | 3296 | #endif |
| 2339 | { | 3297 | { |
| 2340 | b = lshift(b, ++i); | 3298 | b = lshift(b, ++i MTa); |
| 2341 | b->x[0] |= 1; | 3299 | b->x[0] |= 1; |
| 2342 | } | 3300 | } |
| 2343 | #ifndef Sudden_Underflow | 3301 | #ifndef Sudden_Underflow |
| 2344 | have_i: | 3302 | have_i: |
| 2345 | #endif | 3303 | #endif |
| 2346 | p2 -= p5 + i; | 3304 | p2 -= p5 + i; |
| 2347 | d = i2b(1); | 3305 | d = i2b(1 MTa); |
| 2348 | /* Arrange for convenient computation of quotients: | 3306 | /* Arrange for convenient computation of quotients: |
| 2349 | * shift left if necessary so divisor has 4 leading 0 bits. | 3307 | * shift left if necessary so divisor has 4 leading 0 bits. |
| 2350 | */ | 3308 | */ |
| 2351 | if (p5 > 0) | 3309 | if (p5 > 0) |
| 2352 | d = pow5mult(d, p5); | 3310 | d = pow5mult(d, p5 MTa); |
| 2353 | else if (p5 < 0) | 3311 | else if (p5 < 0) |
| 2354 | b = pow5mult(b, -p5); | 3312 | b = pow5mult(b, -p5 MTa); |
| 2355 | if (p2 > 0) { | 3313 | if (p2 > 0) { |
| 2356 | b2 = p2; | 3314 | b2 = p2; |
| 2357 | d2 = 0; | 3315 | d2 = 0; |
| @@ -2362,15 +3320,15 @@ bigcomp | |||
| 2362 | } | 3320 | } |
| 2363 | i = dshift(d, d2); | 3321 | i = dshift(d, d2); |
| 2364 | if ((b2 += i) > 0) | 3322 | if ((b2 += i) > 0) |
| 2365 | b = lshift(b, b2); | 3323 | b = lshift(b, b2 MTa); |
| 2366 | if ((d2 += i) > 0) | 3324 | if ((d2 += i) > 0) |
| 2367 | d = lshift(d, d2); | 3325 | d = lshift(d, d2 MTa); |
| 2368 | 3326 | ||
| 2369 | /* Now b/d = exactly half-way between the two floating-point values */ | 3327 | /* Now b/d = exactly half-way between the two floating-point values */ |
| 2370 | /* on either side of the input string. Compute first digit of b/d. */ | 3328 | /* on either side of the input string. Compute first digit of b/d. */ |
| 2371 | 3329 | ||
| 2372 | if (!(dig = quorem(b,d))) { | 3330 | if (!(dig = quorem(b,d))) { |
| 2373 | b = multadd(b, 10, 0); /* very unlikely */ | 3331 | b = multadd(b, 10, 0 MTa); /* very unlikely */ |
| 2374 | dig = quorem(b,d); | 3332 | dig = quorem(b,d); |
| 2375 | } | 3333 | } |
| 2376 | 3334 | ||
| @@ -2384,7 +3342,7 @@ bigcomp | |||
| 2384 | dd = 1; | 3342 | dd = 1; |
| 2385 | goto ret; | 3343 | goto ret; |
| 2386 | } | 3344 | } |
| 2387 | b = multadd(b, 10, 0); | 3345 | b = multadd(b, 10, 0 MTa); |
| 2388 | dig = quorem(b,d); | 3346 | dig = quorem(b,d); |
| 2389 | } | 3347 | } |
| 2390 | for(j = bc->dp1; i++ < nd;) { | 3348 | for(j = bc->dp1; i++ < nd;) { |
| @@ -2395,14 +3353,14 @@ bigcomp | |||
| 2395 | dd = 1; | 3353 | dd = 1; |
| 2396 | goto ret; | 3354 | goto ret; |
| 2397 | } | 3355 | } |
| 2398 | b = multadd(b, 10, 0); | 3356 | b = multadd(b, 10, 0 MTa); |
| 2399 | dig = quorem(b,d); | 3357 | dig = quorem(b,d); |
| 2400 | } | 3358 | } |
| 2401 | if (b->x[0] || b->wds > 1) | 3359 | if (dig > 0 || b->x[0] || b->wds > 1) |
| 2402 | dd = -1; | 3360 | dd = -1; |
| 2403 | ret: | 3361 | ret: |
| 2404 | Bfree(b); | 3362 | Bfree(b MTa); |
| 2405 | Bfree(d); | 3363 | Bfree(d MTa); |
| 2406 | #ifdef Honor_FLT_ROUNDS | 3364 | #ifdef Honor_FLT_ROUNDS |
| 2407 | if (bc->rounding != 1) { | 3365 | if (bc->rounding != 1) { |
| 2408 | if (dd < 0) { | 3366 | if (dd < 0) { |
| @@ -2451,10 +3409,10 @@ retlow1: | |||
| 2451 | if ((j = ((word0(rv) & Exp_mask) >> Exp_shift) - bc->scale) <= 0) { | 3409 | if ((j = ((word0(rv) & Exp_mask) >> Exp_shift) - bc->scale) <= 0) { |
| 2452 | i = 1 - j; | 3410 | i = 1 - j; |
| 2453 | if (i <= 31) { | 3411 | if (i <= 31) { |
| 2454 | if (word1(rv) & (0x1U << i)) | 3412 | if (word1(rv) & (0x1 << i)) |
| 2455 | goto odd; | 3413 | goto odd; |
| 2456 | } | 3414 | } |
| 2457 | else if (word0(rv) & (0x1U << (i-32))) | 3415 | else if (word0(rv) & (0x1 << (i-32))) |
| 2458 | goto odd; | 3416 | goto odd; |
| 2459 | } | 3417 | } |
| 2460 | else if (word1(rv) & 1) { | 3418 | else if (word1(rv) & 1) { |
| @@ -2473,26 +3431,22 @@ retlow1: | |||
| 2473 | #endif /* NO_STRTOD_BIGCOMP */ | 3431 | #endif /* NO_STRTOD_BIGCOMP */ |
| 2474 | 3432 | ||
| 2475 | double | 3433 | double |
| 2476 | fpconv_strtod | 3434 | fpconv_strtod(const char *s00, char **se) |
| 2477 | #ifdef KR_headers | ||
| 2478 | (s00, se) CONST char *s00; char **se; | ||
| 2479 | #else | ||
| 2480 | (const char *s00, char **se) | ||
| 2481 | #endif | ||
| 2482 | { | 3435 | { |
| 2483 | int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1; | 3436 | int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1; |
| 2484 | int esign, i, j, k, nd, nd0, nf, nz, nz0, nz1, sign; | 3437 | int esign, i, j, k, nd, nd0, nf, nz, nz0, nz1, sign; |
| 2485 | CONST char *s, *s0, *s1; | 3438 | const char *s, *s0, *s1; |
| 2486 | double aadj, aadj1; | 3439 | double aadj, aadj1; |
| 2487 | Long L; | 3440 | Long L; |
| 2488 | U aadj2, adj, rv, rv0; | 3441 | U aadj2, adj, rv, rv0; |
| 2489 | ULong y, z; | 3442 | ULong y, z; |
| 2490 | BCinfo bc; | 3443 | BCinfo bc; |
| 2491 | Bigint *bb1, *bd0; | 3444 | Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; |
| 2492 | Bigint *bb = NULL; | 3445 | #ifdef USE_BF96 |
| 2493 | Bigint *bd = NULL; | 3446 | ULLong bhi, blo, brv, t00, t01, t02, t10, t11, terv, tg, tlo, yz; |
| 2494 | Bigint *bs = NULL; | 3447 | const BF96 *p10; |
| 2495 | Bigint *delta = NULL; | 3448 | int bexact, erv; |
| 3449 | #endif | ||
| 2496 | #ifdef Avoid_Underflow | 3450 | #ifdef Avoid_Underflow |
| 2497 | ULong Lsb, Lsb1; | 3451 | ULong Lsb, Lsb1; |
| 2498 | #endif | 3452 | #endif |
| @@ -2502,6 +3456,9 @@ fpconv_strtod | |||
| 2502 | #ifndef NO_STRTOD_BIGCOMP | 3456 | #ifndef NO_STRTOD_BIGCOMP |
| 2503 | int req_bigcomp = 0; | 3457 | int req_bigcomp = 0; |
| 2504 | #endif | 3458 | #endif |
| 3459 | #ifdef MULTIPLE_THREADS | ||
| 3460 | ThInfo *TI = 0; | ||
| 3461 | #endif | ||
| 2505 | #ifdef Honor_FLT_ROUNDS /*{*/ | 3462 | #ifdef Honor_FLT_ROUNDS /*{*/ |
| 2506 | #ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ | 3463 | #ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ |
| 2507 | bc.rounding = Flt_Rounds; | 3464 | bc.rounding = Flt_Rounds; |
| @@ -2515,7 +3472,7 @@ fpconv_strtod | |||
| 2515 | #endif /*}}*/ | 3472 | #endif /*}}*/ |
| 2516 | #endif /*}*/ | 3473 | #endif /*}*/ |
| 2517 | #ifdef USE_LOCALE | 3474 | #ifdef USE_LOCALE |
| 2518 | CONST char *s2; | 3475 | const char *s2; |
| 2519 | #endif | 3476 | #endif |
| 2520 | 3477 | ||
| 2521 | sign = nz0 = nz1 = nz = bc.dplen = bc.uflchk = 0; | 3478 | sign = nz0 = nz1 = nz = bc.dplen = bc.uflchk = 0; |
| @@ -2547,9 +3504,9 @@ fpconv_strtod | |||
| 2547 | case 'x': | 3504 | case 'x': |
| 2548 | case 'X': | 3505 | case 'X': |
| 2549 | #ifdef Honor_FLT_ROUNDS | 3506 | #ifdef Honor_FLT_ROUNDS |
| 2550 | gethex(&s, &rv, bc.rounding, sign); | 3507 | gethex(&s, &rv, bc.rounding, sign MTb); |
| 2551 | #else | 3508 | #else |
| 2552 | gethex(&s, &rv, 1, sign); | 3509 | gethex(&s, &rv, 1, sign MTb); |
| 2553 | #endif | 3510 | #endif |
| 2554 | goto ret; | 3511 | goto ret; |
| 2555 | } | 3512 | } |
| @@ -2560,12 +3517,20 @@ fpconv_strtod | |||
| 2560 | goto ret; | 3517 | goto ret; |
| 2561 | } | 3518 | } |
| 2562 | s0 = s; | 3519 | s0 = s; |
| 3520 | nd = nf = 0; | ||
| 3521 | #ifdef USE_BF96 | ||
| 3522 | yz = 0; | ||
| 3523 | for(; (c = *s) >= '0' && c <= '9'; nd++, s++) | ||
| 3524 | if (nd < 19) | ||
| 3525 | yz = 10*yz + c - '0'; | ||
| 3526 | #else | ||
| 2563 | y = z = 0; | 3527 | y = z = 0; |
| 2564 | for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) | 3528 | for(; (c = *s) >= '0' && c <= '9'; nd++, s++) |
| 2565 | if (nd < 9) | 3529 | if (nd < 9) |
| 2566 | y = 10*y + c - '0'; | 3530 | y = 10*y + c - '0'; |
| 2567 | else if (nd < 16) | 3531 | else if (nd < DBL_DIG + 2) |
| 2568 | z = 10*z + c - '0'; | 3532 | z = 10*z + c - '0'; |
| 3533 | #endif | ||
| 2569 | nd0 = nd; | 3534 | nd0 = nd; |
| 2570 | bc.dp0 = bc.dp1 = s - s0; | 3535 | bc.dp0 = bc.dp1 = s - s0; |
| 2571 | for(s1 = s; s1 > s0 && *--s1 == '0'; ) | 3536 | for(s1 = s; s1 > s0 && *--s1 == '0'; ) |
| @@ -2611,15 +3576,26 @@ fpconv_strtod | |||
| 2611 | nz++; | 3576 | nz++; |
| 2612 | if (c -= '0') { | 3577 | if (c -= '0') { |
| 2613 | nf += nz; | 3578 | nf += nz; |
| 2614 | for(i = 1; i < nz; i++) | 3579 | i = 1; |
| 3580 | #ifdef USE_BF96 | ||
| 3581 | for(; i < nz; ++i) { | ||
| 3582 | if (++nd <= 19) | ||
| 3583 | yz *= 10; | ||
| 3584 | } | ||
| 3585 | if (++nd <= 19) | ||
| 3586 | yz = 10*yz + c; | ||
| 3587 | #else | ||
| 3588 | for(; i < nz; ++i) { | ||
| 2615 | if (nd++ < 9) | 3589 | if (nd++ < 9) |
| 2616 | y *= 10; | 3590 | y *= 10; |
| 2617 | else if (nd <= DBL_DIG + 1) | 3591 | else if (nd <= DBL_DIG + 2) |
| 2618 | z *= 10; | 3592 | z *= 10; |
| 3593 | } | ||
| 2619 | if (nd++ < 9) | 3594 | if (nd++ < 9) |
| 2620 | y = 10*y + c; | 3595 | y = 10*y + c; |
| 2621 | else if (nd <= DBL_DIG + 1) | 3596 | else if (nd <= DBL_DIG + 2) |
| 2622 | z = 10*z + c; | 3597 | z = 10*z + c; |
| 3598 | #endif | ||
| 2623 | nz = nz1 = 0; | 3599 | nz = nz1 = 0; |
| 2624 | } | 3600 | } |
| 2625 | } | 3601 | } |
| @@ -2664,7 +3640,7 @@ fpconv_strtod | |||
| 2664 | } | 3640 | } |
| 2665 | if (!nd) { | 3641 | if (!nd) { |
| 2666 | if (!nz && !nz0) { | 3642 | if (!nz && !nz0) { |
| 2667 | #ifdef INFNAN_CHECK | 3643 | #ifdef INFNAN_CHECK /*{*/ |
| 2668 | /* Check for Nan and Infinity */ | 3644 | /* Check for Nan and Infinity */ |
| 2669 | if (!bc.dplen) | 3645 | if (!bc.dplen) |
| 2670 | switch(c) { | 3646 | switch(c) { |
| @@ -2691,7 +3667,7 @@ fpconv_strtod | |||
| 2691 | goto ret; | 3667 | goto ret; |
| 2692 | } | 3668 | } |
| 2693 | } | 3669 | } |
| 2694 | #endif /* INFNAN_CHECK */ | 3670 | #endif /*} INFNAN_CHECK */ |
| 2695 | ret0: | 3671 | ret0: |
| 2696 | s = s00; | 3672 | s = s00; |
| 2697 | sign = 0; | 3673 | sign = 0; |
| @@ -2707,7 +3683,8 @@ fpconv_strtod | |||
| 2707 | 3683 | ||
| 2708 | if (!nd0) | 3684 | if (!nd0) |
| 2709 | nd0 = nd; | 3685 | nd0 = nd; |
| 2710 | k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; | 3686 | #ifndef USE_BF96 |
| 3687 | k = nd < DBL_DIG + 2 ? nd : DBL_DIG + 2; | ||
| 2711 | dval(&rv) = y; | 3688 | dval(&rv) = y; |
| 2712 | if (k > 9) { | 3689 | if (k > 9) { |
| 2713 | #ifdef SET_INEXACT | 3690 | #ifdef SET_INEXACT |
| @@ -2716,6 +3693,7 @@ fpconv_strtod | |||
| 2716 | #endif | 3693 | #endif |
| 2717 | dval(&rv) = tens[k - 9] * dval(&rv) + z; | 3694 | dval(&rv) = tens[k - 9] * dval(&rv) + z; |
| 2718 | } | 3695 | } |
| 3696 | #endif | ||
| 2719 | bd0 = 0; | 3697 | bd0 = 0; |
| 2720 | if (nd <= DBL_DIG | 3698 | if (nd <= DBL_DIG |
| 2721 | #ifndef RND_PRODQUOT | 3699 | #ifndef RND_PRODQUOT |
| @@ -2724,11 +3702,18 @@ fpconv_strtod | |||
| 2724 | #endif | 3702 | #endif |
| 2725 | #endif | 3703 | #endif |
| 2726 | ) { | 3704 | ) { |
| 3705 | #ifdef USE_BF96 | ||
| 3706 | dval(&rv) = yz; | ||
| 3707 | #endif | ||
| 2727 | if (!e) | 3708 | if (!e) |
| 2728 | goto ret; | 3709 | goto ret; |
| 2729 | #ifndef ROUND_BIASED_without_Round_Up | 3710 | #ifndef ROUND_BIASED_without_Round_Up |
| 2730 | if (e > 0) { | 3711 | if (e > 0) { |
| 2731 | if (e <= Ten_pmax) { | 3712 | if (e <= Ten_pmax) { |
| 3713 | #ifdef SET_INEXACT | ||
| 3714 | bc.inexact = 0; | ||
| 3715 | oldinexact = 1; | ||
| 3716 | #endif | ||
| 2732 | #ifdef VAX | 3717 | #ifdef VAX |
| 2733 | goto vax_ovfl_check; | 3718 | goto vax_ovfl_check; |
| 2734 | #else | 3719 | #else |
| @@ -2748,6 +3733,10 @@ fpconv_strtod | |||
| 2748 | /* A fancier test would sometimes let us do | 3733 | /* A fancier test would sometimes let us do |
| 2749 | * this for larger i values. | 3734 | * this for larger i values. |
| 2750 | */ | 3735 | */ |
| 3736 | #ifdef SET_INEXACT | ||
| 3737 | bc.inexact = 0; | ||
| 3738 | oldinexact = 1; | ||
| 3739 | #endif | ||
| 2751 | #ifdef Honor_FLT_ROUNDS | 3740 | #ifdef Honor_FLT_ROUNDS |
| 2752 | /* round correctly FLT_ROUNDS = 2 or 3 */ | 3741 | /* round correctly FLT_ROUNDS = 2 or 3 */ |
| 2753 | if (sign) { | 3742 | if (sign) { |
| @@ -2776,6 +3765,10 @@ fpconv_strtod | |||
| 2776 | } | 3765 | } |
| 2777 | #ifndef Inaccurate_Divide | 3766 | #ifndef Inaccurate_Divide |
| 2778 | else if (e >= -Ten_pmax) { | 3767 | else if (e >= -Ten_pmax) { |
| 3768 | #ifdef SET_INEXACT | ||
| 3769 | bc.inexact = 0; | ||
| 3770 | oldinexact = 1; | ||
| 3771 | #endif | ||
| 2779 | #ifdef Honor_FLT_ROUNDS | 3772 | #ifdef Honor_FLT_ROUNDS |
| 2780 | /* round correctly FLT_ROUNDS = 2 or 3 */ | 3773 | /* round correctly FLT_ROUNDS = 2 or 3 */ |
| 2781 | if (sign) { | 3774 | if (sign) { |
| @@ -2789,16 +3782,18 @@ fpconv_strtod | |||
| 2789 | #endif | 3782 | #endif |
| 2790 | #endif /* ROUND_BIASED_without_Round_Up */ | 3783 | #endif /* ROUND_BIASED_without_Round_Up */ |
| 2791 | } | 3784 | } |
| 2792 | e1 += nd - k; | 3785 | #ifdef USE_BF96 |
| 3786 | k = nd < 19 ? nd : 19; | ||
| 3787 | #endif | ||
| 3788 | e1 += nd - k; /* scale factor = 10^e1 */ | ||
| 2793 | 3789 | ||
| 2794 | #ifdef IEEE_Arith | 3790 | #ifdef IEEE_Arith |
| 2795 | #ifdef SET_INEXACT | 3791 | #ifdef SET_INEXACT |
| 2796 | bc.inexact = 1; | 3792 | bc.inexact = 1; |
| 3793 | #ifndef USE_BF96 | ||
| 2797 | if (k <= DBL_DIG) | 3794 | if (k <= DBL_DIG) |
| 2798 | oldinexact = get_inexact(); | ||
| 2799 | #endif | 3795 | #endif |
| 2800 | #ifdef Avoid_Underflow | 3796 | oldinexact = get_inexact(); |
| 2801 | bc.scale = 0; | ||
| 2802 | #endif | 3797 | #endif |
| 2803 | #ifdef Honor_FLT_ROUNDS | 3798 | #ifdef Honor_FLT_ROUNDS |
| 2804 | if (bc.rounding >= 2) { | 3799 | if (bc.rounding >= 2) { |
| @@ -2811,6 +3806,315 @@ fpconv_strtod | |||
| 2811 | #endif | 3806 | #endif |
| 2812 | #endif /*IEEE_Arith*/ | 3807 | #endif /*IEEE_Arith*/ |
| 2813 | 3808 | ||
| 3809 | #ifdef USE_BF96 /*{*/ | ||
| 3810 | Debug(++dtoa_stats[0]); | ||
| 3811 | i = e1 + 342; | ||
| 3812 | if (i < 0) | ||
| 3813 | goto undfl; | ||
| 3814 | if (i > 650) | ||
| 3815 | goto ovfl; | ||
| 3816 | p10 = &pten[i]; | ||
| 3817 | brv = yz; | ||
| 3818 | /* shift brv left, with i = number of bits shifted */ | ||
| 3819 | i = 0; | ||
| 3820 | if (!(brv & 0xffffffff00000000ull)) { | ||
| 3821 | i = 32; | ||
| 3822 | brv <<= 32; | ||
| 3823 | } | ||
| 3824 | if (!(brv & 0xffff000000000000ull)) { | ||
| 3825 | i += 16; | ||
| 3826 | brv <<= 16; | ||
| 3827 | } | ||
| 3828 | if (!(brv & 0xff00000000000000ull)) { | ||
| 3829 | i += 8; | ||
| 3830 | brv <<= 8; | ||
| 3831 | } | ||
| 3832 | if (!(brv & 0xf000000000000000ull)) { | ||
| 3833 | i += 4; | ||
| 3834 | brv <<= 4; | ||
| 3835 | } | ||
| 3836 | if (!(brv & 0xc000000000000000ull)) { | ||
| 3837 | i += 2; | ||
| 3838 | brv <<= 2; | ||
| 3839 | } | ||
| 3840 | if (!(brv & 0x8000000000000000ull)) { | ||
| 3841 | i += 1; | ||
| 3842 | brv <<= 1; | ||
| 3843 | } | ||
| 3844 | erv = (64 + 0x3fe) + p10->e - i; | ||
| 3845 | if (erv <= 0 && nd > 19) | ||
| 3846 | goto many_digits; /* denormal: may need to look at all digits */ | ||
| 3847 | bhi = brv >> 32; | ||
| 3848 | blo = brv & 0xffffffffull; | ||
| 3849 | /* Unsigned 32-bit ints lie in [0,2^32-1] and */ | ||
| 3850 | /* unsigned 64-bit ints lie in [0, 2^64-1]. The product of two unsigned */ | ||
| 3851 | /* 32-bit ints is <= 2^64 - 2*2^32-1 + 1 = 2^64 - 1 - 2*(2^32 - 1), so */ | ||
| 3852 | /* we can add two unsigned 32-bit ints to the product of two such ints, */ | ||
| 3853 | /* and 64 bits suffice to contain the result. */ | ||
| 3854 | t01 = bhi * p10->b1; | ||
| 3855 | t10 = blo * p10->b0 + (t01 & 0xffffffffull); | ||
| 3856 | t00 = bhi * p10->b0 + (t01 >> 32) + (t10 >> 32); | ||
| 3857 | if (t00 & 0x8000000000000000ull) { | ||
| 3858 | if ((t00 & 0x3ff) && (~t00 & 0x3fe)) { /* unambiguous result? */ | ||
| 3859 | if (nd > 19 && ((t00 + (1<<i) + 2) & 0x400) ^ (t00 & 0x400)) | ||
| 3860 | goto many_digits; | ||
| 3861 | if (erv <= 0) | ||
| 3862 | goto denormal; | ||
| 3863 | #ifdef Honor_FLT_ROUNDS | ||
| 3864 | switch(bc.rounding) { | ||
| 3865 | case 0: goto noround; | ||
| 3866 | case 2: goto roundup; | ||
| 3867 | } | ||
| 3868 | #endif | ||
| 3869 | if (t00 & 0x400 && t00 & 0xbff) | ||
| 3870 | goto roundup; | ||
| 3871 | goto noround; | ||
| 3872 | } | ||
| 3873 | } | ||
| 3874 | else { | ||
| 3875 | if ((t00 & 0x1ff) && (~t00 & 0x1fe)) { /* unambiguous result? */ | ||
| 3876 | if (nd > 19 && ((t00 + (1<<i) + 2) & 0x200) ^ (t00 & 0x200)) | ||
| 3877 | goto many_digits; | ||
| 3878 | if (erv <= 1) | ||
| 3879 | goto denormal1; | ||
| 3880 | #ifdef Honor_FLT_ROUNDS | ||
| 3881 | switch(bc.rounding) { | ||
| 3882 | case 0: goto noround1; | ||
| 3883 | case 2: goto roundup1; | ||
| 3884 | } | ||
| 3885 | #endif | ||
| 3886 | if (t00 & 0x200) | ||
| 3887 | goto roundup1; | ||
| 3888 | goto noround1; | ||
| 3889 | } | ||
| 3890 | } | ||
| 3891 | /* 3 multiplies did not suffice; try a 96-bit approximation */ | ||
| 3892 | Debug(++dtoa_stats[1]); | ||
| 3893 | t02 = bhi * p10->b2; | ||
| 3894 | t11 = blo * p10->b1 + (t02 & 0xffffffffull); | ||
| 3895 | bexact = 1; | ||
| 3896 | if (e1 < 0 || e1 > 41 || (t10 | t11) & 0xffffffffull || nd > 19) | ||
| 3897 | bexact = 0; | ||
| 3898 | tlo = (t10 & 0xffffffffull) + (t02 >> 32) + (t11 >> 32); | ||
| 3899 | if (!bexact && (tlo + 0x10) >> 32 > tlo >> 32) | ||
| 3900 | goto many_digits; | ||
| 3901 | t00 += tlo >> 32; | ||
| 3902 | if (t00 & 0x8000000000000000ull) { | ||
| 3903 | if (erv <= 0) { /* denormal result */ | ||
| 3904 | if (nd >= 20 || !((tlo & 0xfffffff0) | (t00 & 0x3ff))) | ||
| 3905 | goto many_digits; | ||
| 3906 | denormal: | ||
| 3907 | if (erv <= -52) { | ||
| 3908 | #ifdef Honor_FLT_ROUNDS | ||
| 3909 | switch(bc.rounding) { | ||
| 3910 | case 0: goto undfl; | ||
| 3911 | case 2: goto tiniest; | ||
| 3912 | } | ||
| 3913 | #endif | ||
| 3914 | if (erv < -52 || !(t00 & 0x7fffffffffffffffull)) | ||
| 3915 | goto undfl; | ||
| 3916 | goto tiniest; | ||
| 3917 | } | ||
| 3918 | tg = 1ull << (11 - erv); | ||
| 3919 | t00 &= ~(tg - 1); /* clear low bits */ | ||
| 3920 | #ifdef Honor_FLT_ROUNDS | ||
| 3921 | switch(bc.rounding) { | ||
| 3922 | case 0: goto noround_den; | ||
| 3923 | case 2: goto roundup_den; | ||
| 3924 | } | ||
| 3925 | #endif | ||
| 3926 | if (t00 & tg) { | ||
| 3927 | #ifdef Honor_FLT_ROUNDS | ||
| 3928 | roundup_den: | ||
| 3929 | #endif | ||
| 3930 | t00 += tg << 1; | ||
| 3931 | if (!(t00 & 0x8000000000000000ull)) { | ||
| 3932 | if (++erv > 0) | ||
| 3933 | goto smallest_normal; | ||
| 3934 | t00 = 0x8000000000000000ull; | ||
| 3935 | } | ||
| 3936 | } | ||
| 3937 | #ifdef Honor_FLT_ROUNDS | ||
| 3938 | noround_den: | ||
| 3939 | #endif | ||
| 3940 | LLval(&rv) = t00 >> (12 - erv); | ||
| 3941 | Set_errno(ERANGE); | ||
| 3942 | goto ret; | ||
| 3943 | } | ||
| 3944 | if (bexact) { | ||
| 3945 | #ifdef SET_INEXACT | ||
| 3946 | if (!(t00 & 0x7ff) && !(tlo & 0xffffffffull)) { | ||
| 3947 | bc.inexact = 0; | ||
| 3948 | goto noround; | ||
| 3949 | } | ||
| 3950 | #endif | ||
| 3951 | #ifdef Honor_FLT_ROUNDS | ||
| 3952 | switch(bc.rounding) { | ||
| 3953 | case 2: | ||
| 3954 | if (t00 & 0x7ff) | ||
| 3955 | goto roundup; | ||
| 3956 | case 0: goto noround; | ||
| 3957 | } | ||
| 3958 | #endif | ||
| 3959 | if (t00 & 0x400 && (tlo & 0xffffffff) | (t00 & 0xbff)) | ||
| 3960 | goto roundup; | ||
| 3961 | goto noround; | ||
| 3962 | } | ||
| 3963 | if ((tlo & 0xfffffff0) | (t00 & 0x3ff) | ||
| 3964 | && (nd <= 19 || ((t00 + (1ull << i)) & 0xfffffffffffffc00ull) | ||
| 3965 | == (t00 & 0xfffffffffffffc00ull))) { | ||
| 3966 | /* Unambiguous result. */ | ||
| 3967 | /* If nd > 19, then incrementing the 19th digit */ | ||
| 3968 | /* does not affect rv. */ | ||
| 3969 | #ifdef Honor_FLT_ROUNDS | ||
| 3970 | switch(bc.rounding) { | ||
| 3971 | case 0: goto noround; | ||
| 3972 | case 2: goto roundup; | ||
| 3973 | } | ||
| 3974 | #endif | ||
| 3975 | if (t00 & 0x400) { /* round up */ | ||
| 3976 | roundup: | ||
| 3977 | t00 += 0x800; | ||
| 3978 | if (!(t00 & 0x8000000000000000ull)) { | ||
| 3979 | /* rounded up to a power of 2 */ | ||
| 3980 | if (erv >= 0x7fe) | ||
| 3981 | goto ovfl; | ||
| 3982 | terv = erv + 1; | ||
| 3983 | LLval(&rv) = terv << 52; | ||
| 3984 | goto ret; | ||
| 3985 | } | ||
| 3986 | } | ||
| 3987 | noround: | ||
| 3988 | if (erv >= 0x7ff) | ||
| 3989 | goto ovfl; | ||
| 3990 | terv = erv; | ||
| 3991 | LLval(&rv) = (terv << 52) | ((t00 & 0x7ffffffffffff800ull) >> 11); | ||
| 3992 | goto ret; | ||
| 3993 | } | ||
| 3994 | } | ||
| 3995 | else { | ||
| 3996 | if (erv <= 1) { /* denormal result */ | ||
| 3997 | if (nd >= 20 || !((tlo & 0xfffffff0) | (t00 & 0x1ff))) | ||
| 3998 | goto many_digits; | ||
| 3999 | denormal1: | ||
| 4000 | if (erv <= -51) { | ||
| 4001 | #ifdef Honor_FLT_ROUNDS | ||
| 4002 | switch(bc.rounding) { | ||
| 4003 | case 0: goto undfl; | ||
| 4004 | case 2: goto tiniest; | ||
| 4005 | } | ||
| 4006 | #endif | ||
| 4007 | if (erv < -51 || !(t00 & 0x3fffffffffffffffull)) | ||
| 4008 | goto undfl; | ||
| 4009 | tiniest: | ||
| 4010 | LLval(&rv) = 1; | ||
| 4011 | Set_errno(ERANGE); | ||
| 4012 | goto ret; | ||
| 4013 | } | ||
| 4014 | tg = 1ull << (11 - erv); | ||
| 4015 | #ifdef Honor_FLT_ROUNDS | ||
| 4016 | switch(bc.rounding) { | ||
| 4017 | case 0: goto noround1_den; | ||
| 4018 | case 2: goto roundup1_den; | ||
| 4019 | } | ||
| 4020 | #endif | ||
| 4021 | if (t00 & tg) { | ||
| 4022 | #ifdef Honor_FLT_ROUNDS | ||
| 4023 | roundup1_den: | ||
| 4024 | #endif | ||
| 4025 | if (0x8000000000000000ull & (t00 += (tg<<1)) && erv == 1) { | ||
| 4026 | |||
| 4027 | smallest_normal: | ||
| 4028 | LLval(&rv) = 0x0010000000000000ull; | ||
| 4029 | goto ret; | ||
| 4030 | } | ||
| 4031 | } | ||
| 4032 | #ifdef Honor_FLT_ROUNDS | ||
| 4033 | noround1_den: | ||
| 4034 | #endif | ||
| 4035 | if (erv <= -52) | ||
| 4036 | goto undfl; | ||
| 4037 | LLval(&rv) = t00 >> (12 - erv); | ||
| 4038 | Set_errno(ERANGE); | ||
| 4039 | goto ret; | ||
| 4040 | } | ||
| 4041 | if (bexact) { | ||
| 4042 | #ifdef SET_INEXACT | ||
| 4043 | if (!(t00 & 0x3ff) && !(tlo & 0xffffffffull)) { | ||
| 4044 | bc.inexact = 0; | ||
| 4045 | goto noround1; | ||
| 4046 | } | ||
| 4047 | #endif | ||
| 4048 | #ifdef Honor_FLT_ROUNDS | ||
| 4049 | switch(bc.rounding) { | ||
| 4050 | case 2: | ||
| 4051 | if (t00 & 0x3ff) | ||
| 4052 | goto roundup1; | ||
| 4053 | case 0: goto noround1; | ||
| 4054 | } | ||
| 4055 | #endif | ||
| 4056 | if (t00 & 0x200 && (t00 & 0x5ff || tlo)) | ||
| 4057 | goto roundup1; | ||
| 4058 | goto noround1; | ||
| 4059 | } | ||
| 4060 | if ((tlo & 0xfffffff0) | (t00 & 0x1ff) | ||
| 4061 | && (nd <= 19 || ((t00 + (1ull << i)) & 0x7ffffffffffffe00ull) | ||
| 4062 | == (t00 & 0x7ffffffffffffe00ull))) { | ||
| 4063 | /* Unambiguous result. */ | ||
| 4064 | #ifdef Honor_FLT_ROUNDS | ||
| 4065 | switch(bc.rounding) { | ||
| 4066 | case 0: goto noround1; | ||
| 4067 | case 2: goto roundup1; | ||
| 4068 | } | ||
| 4069 | #endif | ||
| 4070 | if (t00 & 0x200) { /* round up */ | ||
| 4071 | roundup1: | ||
| 4072 | t00 += 0x400; | ||
| 4073 | if (!(t00 & 0x4000000000000000ull)) { | ||
| 4074 | /* rounded up to a power of 2 */ | ||
| 4075 | if (erv >= 0x7ff) | ||
| 4076 | goto ovfl; | ||
| 4077 | terv = erv; | ||
| 4078 | LLval(&rv) = terv << 52; | ||
| 4079 | goto ret; | ||
| 4080 | } | ||
| 4081 | } | ||
| 4082 | noround1: | ||
| 4083 | if (erv >= 0x800) | ||
| 4084 | goto ovfl; | ||
| 4085 | terv = erv - 1; | ||
| 4086 | LLval(&rv) = (terv << 52) | ((t00 & 0x3ffffffffffffc00ull) >> 10); | ||
| 4087 | goto ret; | ||
| 4088 | } | ||
| 4089 | } | ||
| 4090 | many_digits: | ||
| 4091 | Debug(++dtoa_stats[2]); | ||
| 4092 | if (nd > 17) { | ||
| 4093 | if (nd > 18) { | ||
| 4094 | yz /= 100; | ||
| 4095 | e1 += 2; | ||
| 4096 | } | ||
| 4097 | else { | ||
| 4098 | yz /= 10; | ||
| 4099 | e1 += 1; | ||
| 4100 | } | ||
| 4101 | y = yz / 100000000; | ||
| 4102 | } | ||
| 4103 | else if (nd > 9) { | ||
| 4104 | i = nd - 9; | ||
| 4105 | y = (yz >> i) / pfive[i-1]; | ||
| 4106 | } | ||
| 4107 | else | ||
| 4108 | y = yz; | ||
| 4109 | dval(&rv) = yz; | ||
| 4110 | #endif /*}*/ | ||
| 4111 | |||
| 4112 | #ifdef IEEE_Arith | ||
| 4113 | #ifdef Avoid_Underflow | ||
| 4114 | bc.scale = 0; | ||
| 4115 | #endif | ||
| 4116 | #endif /*IEEE_Arith*/ | ||
| 4117 | |||
| 2814 | /* Get starting approximation = rv * 10**e1 */ | 4118 | /* Get starting approximation = rv * 10**e1 */ |
| 2815 | 4119 | ||
| 2816 | if (e1 > 0) { | 4120 | if (e1 > 0) { |
| @@ -2847,15 +4151,13 @@ fpconv_strtod | |||
| 2847 | #endif /*IEEE_Arith*/ | 4151 | #endif /*IEEE_Arith*/ |
| 2848 | range_err: | 4152 | range_err: |
| 2849 | if (bd0) { | 4153 | if (bd0) { |
| 2850 | Bfree(bb); | 4154 | Bfree(bb MTb); |
| 2851 | Bfree(bd); | 4155 | Bfree(bd MTb); |
| 2852 | Bfree(bs); | 4156 | Bfree(bs MTb); |
| 2853 | Bfree(bd0); | 4157 | Bfree(bd0 MTb); |
| 2854 | Bfree(delta); | 4158 | Bfree(delta MTb); |
| 2855 | } | 4159 | } |
| 2856 | #ifndef NO_ERRNO | 4160 | Set_errno(ERANGE); |
| 2857 | errno = ERANGE; | ||
| 2858 | #endif | ||
| 2859 | goto ret; | 4161 | goto ret; |
| 2860 | } | 4162 | } |
| 2861 | e1 >>= 4; | 4163 | e1 >>= 4; |
| @@ -2920,6 +4222,10 @@ fpconv_strtod | |||
| 2920 | if (!dval(&rv)) { | 4222 | if (!dval(&rv)) { |
| 2921 | undfl: | 4223 | undfl: |
| 2922 | dval(&rv) = 0.; | 4224 | dval(&rv) = 0.; |
| 4225 | #ifdef Honor_FLT_ROUNDS | ||
| 4226 | if (bc.rounding == 2) | ||
| 4227 | word1(&rv) = 1; | ||
| 4228 | #endif | ||
| 2923 | goto range_err; | 4229 | goto range_err; |
| 2924 | } | 4230 | } |
| 2925 | #ifndef Avoid_Underflow | 4231 | #ifndef Avoid_Underflow |
| @@ -2969,13 +4275,13 @@ fpconv_strtod | |||
| 2969 | } | 4275 | } |
| 2970 | } | 4276 | } |
| 2971 | #endif | 4277 | #endif |
| 2972 | bd0 = s2b(s0, nd0, nd, y, bc.dplen); | 4278 | bd0 = s2b(s0, nd0, nd, y, bc.dplen MTb); |
| 2973 | 4279 | ||
| 2974 | for(;;) { | 4280 | for(;;) { |
| 2975 | bd = Balloc(bd0->k); | 4281 | bd = Balloc(bd0->k MTb); |
| 2976 | Bcopy(bd, bd0); | 4282 | Bcopy(bd, bd0); |
| 2977 | bb = d2b(&rv, &bbe, &bbbits); /* rv = bb * 2^bbe */ | 4283 | bb = d2b(&rv, &bbe, &bbbits MTb); /* rv = bb * 2^bbe */ |
| 2978 | bs = i2b(1); | 4284 | bs = i2b(1 MTb); |
| 2979 | 4285 | ||
| 2980 | if (e >= 0) { | 4286 | if (e >= 0) { |
| 2981 | bb2 = bb5 = 0; | 4287 | bb2 = bb5 = 0; |
| @@ -3040,20 +4346,20 @@ fpconv_strtod | |||
| 3040 | bs2 -= i; | 4346 | bs2 -= i; |
| 3041 | } | 4347 | } |
| 3042 | if (bb5 > 0) { | 4348 | if (bb5 > 0) { |
| 3043 | bs = pow5mult(bs, bb5); | 4349 | bs = pow5mult(bs, bb5 MTb); |
| 3044 | bb1 = mult(bs, bb); | 4350 | bb1 = mult(bs, bb MTb); |
| 3045 | Bfree(bb); | 4351 | Bfree(bb MTb); |
| 3046 | bb = bb1; | 4352 | bb = bb1; |
| 3047 | } | 4353 | } |
| 3048 | if (bb2 > 0) | 4354 | if (bb2 > 0) |
| 3049 | bb = lshift(bb, bb2); | 4355 | bb = lshift(bb, bb2 MTb); |
| 3050 | if (bd5 > 0) | 4356 | if (bd5 > 0) |
| 3051 | bd = pow5mult(bd, bd5); | 4357 | bd = pow5mult(bd, bd5 MTb); |
| 3052 | if (bd2 > 0) | 4358 | if (bd2 > 0) |
| 3053 | bd = lshift(bd, bd2); | 4359 | bd = lshift(bd, bd2 MTb); |
| 3054 | if (bs2 > 0) | 4360 | if (bs2 > 0) |
| 3055 | bs = lshift(bs, bs2); | 4361 | bs = lshift(bs, bs2 MTb); |
| 3056 | delta = diff(bb, bd); | 4362 | delta = diff(bb, bd MTb); |
| 3057 | bc.dsign = delta->sign; | 4363 | bc.dsign = delta->sign; |
| 3058 | delta->sign = 0; | 4364 | delta->sign = 0; |
| 3059 | i = cmp(delta, bs); | 4365 | i = cmp(delta, bs); |
| @@ -3104,7 +4410,7 @@ fpconv_strtod | |||
| 3104 | if (y) | 4410 | if (y) |
| 3105 | #endif | 4411 | #endif |
| 3106 | { | 4412 | { |
| 3107 | delta = lshift(delta,Log2P); | 4413 | delta = lshift(delta,Log2P MTb); |
| 3108 | if (cmp(delta, bs) <= 0) | 4414 | if (cmp(delta, bs) <= 0) |
| 3109 | adj.d = -0.5; | 4415 | adj.d = -0.5; |
| 3110 | } | 4416 | } |
| @@ -3196,7 +4502,7 @@ fpconv_strtod | |||
| 3196 | #endif | 4502 | #endif |
| 3197 | break; | 4503 | break; |
| 3198 | } | 4504 | } |
| 3199 | delta = lshift(delta,Log2P); | 4505 | delta = lshift(delta,Log2P MTb); |
| 3200 | if (cmp(delta, bs) > 0) | 4506 | if (cmp(delta, bs) > 0) |
| 3201 | goto drop_down; | 4507 | goto drop_down; |
| 3202 | break; | 4508 | break; |
| @@ -3406,8 +4712,7 @@ fpconv_strtod | |||
| 3406 | goto undfl; | 4712 | goto undfl; |
| 3407 | #else | 4713 | #else |
| 3408 | { | 4714 | { |
| 3409 | if (bc.nd > nd) | 4715 | req_bigcomp = 1; |
| 3410 | bc.dsign = 1; | ||
| 3411 | break; | 4716 | break; |
| 3412 | } | 4717 | } |
| 3413 | #endif | 4718 | #endif |
| @@ -3487,21 +4792,21 @@ fpconv_strtod | |||
| 3487 | } | 4792 | } |
| 3488 | #endif | 4793 | #endif |
| 3489 | cont: | 4794 | cont: |
| 3490 | Bfree(bb); | 4795 | Bfree(bb MTb); |
| 3491 | Bfree(bd); | 4796 | Bfree(bd MTb); |
| 3492 | Bfree(bs); | 4797 | Bfree(bs MTb); |
| 3493 | Bfree(delta); | 4798 | Bfree(delta MTb); |
| 3494 | } | 4799 | } |
| 3495 | Bfree(bb); | 4800 | Bfree(bb MTb); |
| 3496 | Bfree(bd); | 4801 | Bfree(bd MTb); |
| 3497 | Bfree(bs); | 4802 | Bfree(bs MTb); |
| 3498 | Bfree(bd0); | 4803 | Bfree(bd0 MTb); |
| 3499 | Bfree(delta); | 4804 | Bfree(delta MTb); |
| 3500 | #ifndef NO_STRTOD_BIGCOMP | 4805 | #ifndef NO_STRTOD_BIGCOMP |
| 3501 | if (req_bigcomp) { | 4806 | if (req_bigcomp) { |
| 3502 | bd0 = 0; | 4807 | bd0 = 0; |
| 3503 | bc.e0 += nz1; | 4808 | bc.e0 += nz1; |
| 3504 | bigcomp(&rv, s0, &bc); | 4809 | bigcomp(&rv, s0, &bc MTb); |
| 3505 | y = word0(&rv) & Exp_mask; | 4810 | y = word0(&rv) & Exp_mask; |
| 3506 | if (y == Exp_mask) | 4811 | if (y == Exp_mask) |
| 3507 | goto ovfl; | 4812 | goto ovfl; |
| @@ -3509,17 +4814,6 @@ fpconv_strtod | |||
| 3509 | goto undfl; | 4814 | goto undfl; |
| 3510 | } | 4815 | } |
| 3511 | #endif | 4816 | #endif |
| 3512 | #ifdef SET_INEXACT | ||
| 3513 | if (bc.inexact) { | ||
| 3514 | if (!oldinexact) { | ||
| 3515 | word0(&rv0) = Exp_1 + (70 << Exp_shift); | ||
| 3516 | word1(&rv0) = 0; | ||
| 3517 | dval(&rv0) += 1.; | ||
| 3518 | } | ||
| 3519 | } | ||
| 3520 | else if (!oldinexact) | ||
| 3521 | clear_inexact(); | ||
| 3522 | #endif | ||
| 3523 | #ifdef Avoid_Underflow | 4817 | #ifdef Avoid_Underflow |
| 3524 | if (bc.scale) { | 4818 | if (bc.scale) { |
| 3525 | word0(&rv0) = Exp_1 - 2*P*Exp_msk1; | 4819 | word0(&rv0) = Exp_1 - 2*P*Exp_msk1; |
| @@ -3532,18 +4826,27 @@ fpconv_strtod | |||
| 3532 | #else | 4826 | #else |
| 3533 | if (word0(&rv) == 0 && word1(&rv) == 0) | 4827 | if (word0(&rv) == 0 && word1(&rv) == 0) |
| 3534 | #endif | 4828 | #endif |
| 3535 | errno = ERANGE; | 4829 | Set_errno(ERANGE); |
| 3536 | #endif | 4830 | #endif |
| 3537 | } | 4831 | } |
| 3538 | #endif /* Avoid_Underflow */ | 4832 | #endif /* Avoid_Underflow */ |
| 4833 | ret: | ||
| 3539 | #ifdef SET_INEXACT | 4834 | #ifdef SET_INEXACT |
| 3540 | if (bc.inexact && !(word0(&rv) & Exp_mask)) { | 4835 | if (bc.inexact) { |
| 3541 | /* set underflow bit */ | 4836 | if (!(word0(&rv) & Exp_mask)) { |
| 3542 | dval(&rv0) = 1e-300; | 4837 | /* set underflow and inexact bits */ |
| 3543 | dval(&rv0) *= dval(&rv0); | 4838 | dval(&rv0) = 1e-300; |
| 4839 | dval(&rv0) *= dval(&rv0); | ||
| 4840 | } | ||
| 4841 | else if (!oldinexact) { | ||
| 4842 | word0(&rv0) = Exp_1 + (70 << Exp_shift); | ||
| 4843 | word1(&rv0) = 0; | ||
| 4844 | dval(&rv0) += 1.; | ||
| 4845 | } | ||
| 3544 | } | 4846 | } |
| 4847 | else if (!oldinexact) | ||
| 4848 | clear_inexact(); | ||
| 3545 | #endif | 4849 | #endif |
| 3546 | ret: | ||
| 3547 | if (se) | 4850 | if (se) |
| 3548 | *se = (char *)s; | 4851 | *se = (char *)s; |
| 3549 | return sign ? -dval(&rv) : dval(&rv); | 4852 | return sign ? -dval(&rv) : dval(&rv); |
| @@ -3554,11 +4857,7 @@ fpconv_strtod | |||
| 3554 | #endif | 4857 | #endif |
| 3555 | 4858 | ||
| 3556 | static char * | 4859 | static char * |
| 3557 | #ifdef KR_headers | 4860 | rv_alloc(int i MTd) |
| 3558 | rv_alloc(i) int i; | ||
| 3559 | #else | ||
| 3560 | rv_alloc(int i) | ||
| 3561 | #endif | ||
| 3562 | { | 4861 | { |
| 3563 | int j, k, *r; | 4862 | int j, k, *r; |
| 3564 | 4863 | ||
| @@ -3567,7 +4866,7 @@ rv_alloc(int i) | |||
| 3567 | sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; | 4866 | sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; |
| 3568 | j <<= 1) | 4867 | j <<= 1) |
| 3569 | k++; | 4868 | k++; |
| 3570 | r = (int*)Balloc(k); | 4869 | r = (int*)Balloc(k MTa); |
| 3571 | *r = k; | 4870 | *r = k; |
| 3572 | return | 4871 | return |
| 3573 | #ifndef MULTIPLE_THREADS | 4872 | #ifndef MULTIPLE_THREADS |
| @@ -3577,16 +4876,21 @@ rv_alloc(int i) | |||
| 3577 | } | 4876 | } |
| 3578 | 4877 | ||
| 3579 | static char * | 4878 | static char * |
| 3580 | #ifdef KR_headers | 4879 | nrv_alloc(const char *s, char *s0, size_t s0len, char **rve, int n MTd) |
| 3581 | nrv_alloc(s, rve, n) char *s, **rve; int n; | ||
| 3582 | #else | ||
| 3583 | nrv_alloc(const char *s, char **rve, int n) | ||
| 3584 | #endif | ||
| 3585 | { | 4880 | { |
| 3586 | char *rv, *t; | 4881 | char *rv, *t; |
| 3587 | 4882 | ||
| 3588 | t = rv = rv_alloc(n); | 4883 | if (!s0) |
| 3589 | while((*t = *s++)) t++; | 4884 | s0 = rv_alloc(n MTa); |
| 4885 | else if (s0len <= n) { | ||
| 4886 | rv = 0; | ||
| 4887 | t = rv + n; | ||
| 4888 | goto rve_chk; | ||
| 4889 | } | ||
| 4890 | t = rv = s0; | ||
| 4891 | while((*t = *s++)) | ||
| 4892 | ++t; | ||
| 4893 | rve_chk: | ||
| 3590 | if (rve) | 4894 | if (rve) |
| 3591 | *rve = t; | 4895 | *rve = t; |
| 3592 | return rv; | 4896 | return rv; |
| @@ -3599,15 +4903,14 @@ nrv_alloc(const char *s, char **rve, int n) | |||
| 3599 | */ | 4903 | */ |
| 3600 | 4904 | ||
| 3601 | void | 4905 | void |
| 3602 | #ifdef KR_headers | ||
| 3603 | freedtoa(s) char *s; | ||
| 3604 | #else | ||
| 3605 | freedtoa(char *s) | 4906 | freedtoa(char *s) |
| 3606 | #endif | ||
| 3607 | { | 4907 | { |
| 4908 | #ifdef MULTIPLE_THREADS | ||
| 4909 | ThInfo *TI = 0; | ||
| 4910 | #endif | ||
| 3608 | Bigint *b = (Bigint *)((int *)s - 1); | 4911 | Bigint *b = (Bigint *)((int *)s - 1); |
| 3609 | b->maxwds = 1 << (b->k = *(int*)b); | 4912 | b->maxwds = 1 << (b->k = *(int*)b); |
| 3610 | Bfree(b); | 4913 | Bfree(b MTb); |
| 3611 | #ifndef MULTIPLE_THREADS | 4914 | #ifndef MULTIPLE_THREADS |
| 3612 | if (s == dtoa_result) | 4915 | if (s == dtoa_result) |
| 3613 | dtoa_result = 0; | 4916 | dtoa_result = 0; |
| @@ -3649,13 +4952,7 @@ freedtoa(char *s) | |||
| 3649 | */ | 4952 | */ |
| 3650 | 4953 | ||
| 3651 | char * | 4954 | char * |
| 3652 | dtoa | 4955 | dtoa_r(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve, char *buf, size_t blen) |
| 3653 | #ifdef KR_headers | ||
| 3654 | (dd, mode, ndigits, decpt, sign, rve) | ||
| 3655 | double dd; int mode, ndigits, *decpt, *sign; char **rve; | ||
| 3656 | #else | ||
| 3657 | (double dd, int mode, int ndigits, int *decpt, int *sign, char **rve) | ||
| 3658 | #endif | ||
| 3659 | { | 4956 | { |
| 3660 | /* Arguments ndigits, decpt, sign are similar to those | 4957 | /* Arguments ndigits, decpt, sign are similar to those |
| 3661 | of ecvt and fcvt; trailing zeros are suppressed from | 4958 | of ecvt and fcvt; trailing zeros are suppressed from |
| @@ -3687,30 +4984,52 @@ dtoa | |||
| 3687 | 4984 | ||
| 3688 | Values of mode other than 0-9 are treated as mode 0. | 4985 | Values of mode other than 0-9 are treated as mode 0. |
| 3689 | 4986 | ||
| 3690 | Sufficient space is allocated to the return value | 4987 | When not NULL, buf is an output buffer of length blen, which must |
| 3691 | to hold the suppressed trailing zeros. | 4988 | be large enough to accommodate suppressed trailing zeros and a trailing |
| 4989 | null byte. If blen is too small, rv = NULL is returned, in which case | ||
| 4990 | if rve is not NULL, a subsequent call with blen >= (*rve - rv) + 1 | ||
| 4991 | should succeed in returning buf. | ||
| 4992 | |||
| 4993 | When buf is NULL, sufficient space is allocated for the return value, | ||
| 4994 | which, when done using, the caller should pass to freedtoa(). | ||
| 4995 | |||
| 4996 | USE_BF is automatically defined when neither NO_LONG_LONG nor NO_BF96 | ||
| 4997 | is defined. | ||
| 3692 | */ | 4998 | */ |
| 3693 | 4999 | ||
| 3694 | int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, | 5000 | #ifdef MULTIPLE_THREADS |
| 3695 | j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, | 5001 | ThInfo *TI = 0; |
| 3696 | spec_case, try_quick; | 5002 | #endif |
| 3697 | Long L; | 5003 | int bbits, b2, b5, be, dig, i, ilim, ilim1, |
| 3698 | #ifndef Sudden_Underflow | 5004 | j, j1, k, leftright, m2, m5, s2, s5, spec_case; |
| 5005 | #if !defined(Sudden_Underflow) || defined(USE_BF96) | ||
| 3699 | int denorm; | 5006 | int denorm; |
| 3700 | ULong x; | ||
| 3701 | #endif | 5007 | #endif |
| 3702 | Bigint *b, *b1, *delta, *mlo, *mhi, *S; | 5008 | Bigint *b, *b1, *delta, *mlo, *mhi, *S; |
| 3703 | U d2, eps, u; | 5009 | U u; |
| 5010 | char *s; | ||
| 5011 | #ifdef SET_INEXACT | ||
| 5012 | int inexact, oldinexact; | ||
| 5013 | #endif | ||
| 5014 | #ifdef USE_BF96 /*{{*/ | ||
| 5015 | BF96 *p10; | ||
| 5016 | ULLong dbhi, dbits, dblo, den, hb, rb, rblo, res, res0, res3, reslo, sres, | ||
| 5017 | sulp, tv0, tv1, tv2, tv3, ulp, ulplo, ulpmask, ures, ureslo, zb; | ||
| 5018 | int eulp, k1, n2, ulpadj, ulpshift; | ||
| 5019 | #else /*}{*/ | ||
| 5020 | #ifndef Sudden_Underflow | ||
| 5021 | ULong x; | ||
| 5022 | #endif | ||
| 5023 | Long L; | ||
| 5024 | U d2, eps; | ||
| 3704 | double ds; | 5025 | double ds; |
| 3705 | char *s, *s0; | 5026 | int ieps, ilim0, k0, k_check, try_quick; |
| 3706 | #ifndef No_leftright | 5027 | #ifndef No_leftright |
| 3707 | #ifdef IEEE_Arith | 5028 | #ifdef IEEE_Arith |
| 3708 | U eps1; | 5029 | U eps1; |
| 3709 | #endif | 5030 | #endif |
| 3710 | #endif | 5031 | #endif |
| 3711 | #ifdef SET_INEXACT | 5032 | #endif /*}}*/ |
| 3712 | int inexact, oldinexact; | ||
| 3713 | #endif | ||
| 3714 | #ifdef Honor_FLT_ROUNDS /*{*/ | 5033 | #ifdef Honor_FLT_ROUNDS /*{*/ |
| 3715 | int Rounding; | 5034 | int Rounding; |
| 3716 | #ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ | 5035 | #ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ |
| @@ -3725,13 +5044,6 @@ dtoa | |||
| 3725 | #endif /*}}*/ | 5044 | #endif /*}}*/ |
| 3726 | #endif /*}*/ | 5045 | #endif /*}*/ |
| 3727 | 5046 | ||
| 3728 | #ifndef MULTIPLE_THREADS | ||
| 3729 | if (dtoa_result) { | ||
| 3730 | freedtoa(dtoa_result); | ||
| 3731 | dtoa_result = 0; | ||
| 3732 | } | ||
| 3733 | #endif | ||
| 3734 | |||
| 3735 | u.d = dd; | 5047 | u.d = dd; |
| 3736 | if (word0(&u) & Sign_bit) { | 5048 | if (word0(&u) & Sign_bit) { |
| 3737 | /* set sign for everything, including 0's and NaNs */ | 5049 | /* set sign for everything, including 0's and NaNs */ |
| @@ -3752,9 +5064,9 @@ dtoa | |||
| 3752 | *decpt = 9999; | 5064 | *decpt = 9999; |
| 3753 | #ifdef IEEE_Arith | 5065 | #ifdef IEEE_Arith |
| 3754 | if (!word1(&u) && !(word0(&u) & 0xfffff)) | 5066 | if (!word1(&u) && !(word0(&u) & 0xfffff)) |
| 3755 | return nrv_alloc("Infinity", rve, 8); | 5067 | return nrv_alloc("Infinity", buf, blen, rve, 8 MTb); |
| 3756 | #endif | 5068 | #endif |
| 3757 | return nrv_alloc("NaN", rve, 3); | 5069 | return nrv_alloc("NaN", buf, blen, rve, 3 MTb); |
| 3758 | } | 5070 | } |
| 3759 | #endif | 5071 | #endif |
| 3760 | #ifdef IBM | 5072 | #ifdef IBM |
| @@ -3762,11 +5074,14 @@ dtoa | |||
| 3762 | #endif | 5074 | #endif |
| 3763 | if (!dval(&u)) { | 5075 | if (!dval(&u)) { |
| 3764 | *decpt = 1; | 5076 | *decpt = 1; |
| 3765 | return nrv_alloc("0", rve, 1); | 5077 | return nrv_alloc("0", buf, blen, rve, 1 MTb); |
| 3766 | } | 5078 | } |
| 3767 | 5079 | ||
| 3768 | #ifdef SET_INEXACT | 5080 | #ifdef SET_INEXACT |
| 3769 | try_quick = oldinexact = get_inexact(); | 5081 | #ifndef USE_BF96 |
| 5082 | try_quick = | ||
| 5083 | #endif | ||
| 5084 | oldinexact = get_inexact(); | ||
| 3770 | inexact = 1; | 5085 | inexact = 1; |
| 3771 | #endif | 5086 | #endif |
| 3772 | #ifdef Honor_FLT_ROUNDS | 5087 | #ifdef Honor_FLT_ROUNDS |
| @@ -3778,8 +5093,58 @@ dtoa | |||
| 3778 | Rounding = 0; | 5093 | Rounding = 0; |
| 3779 | } | 5094 | } |
| 3780 | #endif | 5095 | #endif |
| 5096 | #ifdef USE_BF96 /*{{*/ | ||
| 5097 | dbits = (u.LL & 0xfffffffffffffull) << 11; /* fraction bits */ | ||
| 5098 | if ((be = u.LL >> 52)) /* biased exponent; nonzero ==> normal */ { | ||
| 5099 | dbits |= 0x8000000000000000ull; | ||
| 5100 | denorm = ulpadj = 0; | ||
| 5101 | } | ||
| 5102 | else { | ||
| 5103 | denorm = 1; | ||
| 5104 | ulpadj = be + 1; | ||
| 5105 | dbits <<= 1; | ||
| 5106 | if (!(dbits & 0xffffffff00000000ull)) { | ||
| 5107 | dbits <<= 32; | ||
| 5108 | be -= 32; | ||
| 5109 | } | ||
| 5110 | if (!(dbits & 0xffff000000000000ull)) { | ||
| 5111 | dbits <<= 16; | ||
| 5112 | be -= 16; | ||
| 5113 | } | ||
| 5114 | if (!(dbits & 0xff00000000000000ull)) { | ||
| 5115 | dbits <<= 8; | ||
| 5116 | be -= 8; | ||
| 5117 | } | ||
| 5118 | if (!(dbits & 0xf000000000000000ull)) { | ||
| 5119 | dbits <<= 4; | ||
| 5120 | be -= 4; | ||
| 5121 | } | ||
| 5122 | if (!(dbits & 0xc000000000000000ull)) { | ||
| 5123 | dbits <<= 2; | ||
| 5124 | be -= 2; | ||
| 5125 | } | ||
| 5126 | if (!(dbits & 0x8000000000000000ull)) { | ||
| 5127 | dbits <<= 1; | ||
| 5128 | be -= 1; | ||
| 5129 | } | ||
| 5130 | assert(be >= -51); | ||
| 5131 | ulpadj -= be; | ||
| 5132 | } | ||
| 5133 | j = Lhint[be + 51]; | ||
| 5134 | p10 = &pten[j]; | ||
| 5135 | dbhi = dbits >> 32; | ||
| 5136 | dblo = dbits & 0xffffffffull; | ||
| 5137 | i = be - 0x3fe; | ||
| 5138 | if (i < p10->e | ||
| 5139 | || (i == p10->e && (dbhi < p10->b0 || (dbhi == p10->b0 && dblo < p10->b1)))) | ||
| 5140 | --j; | ||
| 5141 | k = j - 342; | ||
| 5142 | |||
| 5143 | /* now 10^k <= dd < 10^(k+1) */ | ||
| 3781 | 5144 | ||
| 3782 | b = d2b(&u, &be, &bbits); | 5145 | #else /*}{*/ |
| 5146 | |||
| 5147 | b = d2b(&u, &be, &bbits MTb); | ||
| 3783 | #ifdef Sudden_Underflow | 5148 | #ifdef Sudden_Underflow |
| 3784 | i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); | 5149 | i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); |
| 3785 | #else | 5150 | #else |
| @@ -3864,20 +5229,23 @@ dtoa | |||
| 3864 | b5 = -k; | 5229 | b5 = -k; |
| 3865 | s5 = 0; | 5230 | s5 = 0; |
| 3866 | } | 5231 | } |
| 5232 | #endif /*}}*/ | ||
| 3867 | if (mode < 0 || mode > 9) | 5233 | if (mode < 0 || mode > 9) |
| 3868 | mode = 0; | 5234 | mode = 0; |
| 3869 | 5235 | ||
| 5236 | #ifndef USE_BF96 | ||
| 3870 | #ifndef SET_INEXACT | 5237 | #ifndef SET_INEXACT |
| 3871 | #ifdef Check_FLT_ROUNDS | 5238 | #ifdef Check_FLT_ROUNDS |
| 3872 | try_quick = Rounding == 1; | 5239 | try_quick = Rounding == 1; |
| 3873 | #else | ||
| 3874 | try_quick = 1; | ||
| 3875 | #endif | 5240 | #endif |
| 3876 | #endif /*SET_INEXACT*/ | 5241 | #endif /*SET_INEXACT*/ |
| 5242 | #endif | ||
| 3877 | 5243 | ||
| 3878 | if (mode > 5) { | 5244 | if (mode > 5) { |
| 3879 | mode -= 4; | 5245 | mode -= 4; |
| 5246 | #ifndef USE_BF96 | ||
| 3880 | try_quick = 0; | 5247 | try_quick = 0; |
| 5248 | #endif | ||
| 3881 | } | 5249 | } |
| 3882 | leftright = 1; | 5250 | leftright = 1; |
| 3883 | ilim = ilim1 = -1; /* Values for cases 0 and 1; done here to */ | 5251 | ilim = ilim1 = -1; /* Values for cases 0 and 1; done here to */ |
| @@ -3906,20 +5274,490 @@ dtoa | |||
| 3906 | if (i <= 0) | 5274 | if (i <= 0) |
| 3907 | i = 1; | 5275 | i = 1; |
| 3908 | } | 5276 | } |
| 3909 | s = s0 = rv_alloc(i); | 5277 | if (!buf) { |
| 5278 | buf = rv_alloc(i MTb); | ||
| 5279 | blen = sizeof(Bigint) + ((1 << ((int*)buf)[-1]) - 1)*sizeof(ULong) - sizeof(int); | ||
| 5280 | } | ||
| 5281 | else if (blen <= i) { | ||
| 5282 | buf = 0; | ||
| 5283 | if (rve) | ||
| 5284 | *rve = buf + i; | ||
| 5285 | return buf; | ||
| 5286 | } | ||
| 5287 | s = buf; | ||
| 5288 | |||
| 5289 | /* Check for special case that d is a normalized power of 2. */ | ||
| 5290 | |||
| 5291 | spec_case = 0; | ||
| 5292 | if (mode < 2 || (leftright | ||
| 5293 | #ifdef Honor_FLT_ROUNDS | ||
| 5294 | && Rounding == 1 | ||
| 5295 | #endif | ||
| 5296 | )) { | ||
| 5297 | if (!word1(&u) && !(word0(&u) & Bndry_mask) | ||
| 5298 | #ifndef Sudden_Underflow | ||
| 5299 | && word0(&u) & (Exp_mask & ~Exp_msk1) | ||
| 5300 | #endif | ||
| 5301 | ) { | ||
| 5302 | /* The special case */ | ||
| 5303 | spec_case = 1; | ||
| 5304 | } | ||
| 5305 | } | ||
| 5306 | |||
| 5307 | #ifdef USE_BF96 /*{*/ | ||
| 5308 | b = 0; | ||
| 5309 | if (ilim < 0 && (mode == 3 || mode == 5)) { | ||
| 5310 | S = mhi = 0; | ||
| 5311 | goto no_digits; | ||
| 5312 | } | ||
| 5313 | i = 1; | ||
| 5314 | j = 52 + 0x3ff - be; | ||
| 5315 | ulpshift = 0; | ||
| 5316 | ulplo = 0; | ||
| 5317 | /* Can we do an exact computation with 64-bit integer arithmetic? */ | ||
| 5318 | if (k < 0) { | ||
| 5319 | if (k < -25) | ||
| 5320 | goto toobig; | ||
| 5321 | res = dbits >> 11; | ||
| 5322 | n2 = pfivebits[k1 = -(k + 1)] + 53; | ||
| 5323 | j1 = j; | ||
| 5324 | if (n2 > 61) { | ||
| 5325 | ulpshift = n2 - 61; | ||
| 5326 | if (res & (ulpmask = (1ull << ulpshift) - 1)) | ||
| 5327 | goto toobig; | ||
| 5328 | j -= ulpshift; | ||
| 5329 | res >>= ulpshift; | ||
| 5330 | } | ||
| 5331 | /* Yes. */ | ||
| 5332 | res *= ulp = pfive[k1]; | ||
| 5333 | if (ulpshift) { | ||
| 5334 | ulplo = ulp; | ||
| 5335 | ulp >>= ulpshift; | ||
| 5336 | } | ||
| 5337 | j += k; | ||
| 5338 | if (ilim == 0) { | ||
| 5339 | S = mhi = 0; | ||
| 5340 | if (res > (5ull << j)) | ||
| 5341 | goto one_digit; | ||
| 5342 | goto no_digits; | ||
| 5343 | } | ||
| 5344 | goto no_div; | ||
| 5345 | } | ||
| 5346 | if (ilim == 0 && j + k >= 0) { | ||
| 5347 | S = mhi = 0; | ||
| 5348 | if ((dbits >> 11) > (pfive[k-1] << j)) | ||
| 5349 | goto one_digit; | ||
| 5350 | goto no_digits; | ||
| 5351 | } | ||
| 5352 | if (k <= dtoa_divmax && j + k >= 0) { | ||
| 5353 | /* Another "yes" case -- we will use exact integer arithmetic. */ | ||
| 5354 | use_exact: | ||
| 5355 | Debug(++dtoa_stats[3]); | ||
| 5356 | res = dbits >> 11; /* residual */ | ||
| 5357 | ulp = 1; | ||
| 5358 | if (k <= 0) | ||
| 5359 | goto no_div; | ||
| 5360 | j1 = j + k + 1; | ||
| 5361 | den = pfive[k-i] << (j1 - i); | ||
| 5362 | for(;;) { | ||
| 5363 | dig = res / den; | ||
| 5364 | *s++ = '0' + dig; | ||
| 5365 | if (!(res -= dig*den)) { | ||
| 5366 | #ifdef SET_INEXACT | ||
| 5367 | inexact = 0; | ||
| 5368 | oldinexact = 1; | ||
| 5369 | #endif | ||
| 5370 | goto retc; | ||
| 5371 | } | ||
| 5372 | if (ilim < 0) { | ||
| 5373 | ures = den - res; | ||
| 5374 | if (2*res <= ulp | ||
| 5375 | && (spec_case ? 4*res <= ulp : (2*res < ulp || dig & 1))) | ||
| 5376 | goto ulp_reached; | ||
| 5377 | if (2*ures < ulp) | ||
| 5378 | goto Roundup; | ||
| 5379 | } | ||
| 5380 | else if (i == ilim) { | ||
| 5381 | switch(Rounding) { | ||
| 5382 | case 0: goto retc; | ||
| 5383 | case 2: goto Roundup; | ||
| 5384 | } | ||
| 5385 | ures = 2*res; | ||
| 5386 | if (ures > den | ||
| 5387 | || (ures == den && dig & 1) | ||
| 5388 | || (spec_case && res <= ulp && 2*res >= ulp)) | ||
| 5389 | goto Roundup; | ||
| 5390 | goto retc; | ||
| 5391 | } | ||
| 5392 | if (j1 < ++i) { | ||
| 5393 | res *= 10; | ||
| 5394 | ulp *= 10; | ||
| 5395 | } | ||
| 5396 | else { | ||
| 5397 | if (i > k) | ||
| 5398 | break; | ||
| 5399 | den = pfive[k-i] << (j1 - i); | ||
| 5400 | } | ||
| 5401 | } | ||
| 5402 | no_div: | ||
| 5403 | for(;;) { | ||
| 5404 | dig = den = res >> j; | ||
| 5405 | *s++ = '0' + dig; | ||
| 5406 | if (!(res -= den << j)) { | ||
| 5407 | #ifdef SET_INEXACT | ||
| 5408 | inexact = 0; | ||
| 5409 | oldinexact = 1; | ||
| 5410 | #endif | ||
| 5411 | goto retc; | ||
| 5412 | } | ||
| 5413 | if (ilim < 0) { | ||
| 5414 | ures = (1ull << j) - res; | ||
| 5415 | if (2*res <= ulp | ||
| 5416 | && (spec_case ? 4*res <= ulp : (2*res < ulp || dig & 1))) { | ||
| 5417 | ulp_reached: | ||
| 5418 | if (ures < res | ||
| 5419 | || (ures == res && dig & 1)) | ||
| 5420 | goto Roundup; | ||
| 5421 | goto retc; | ||
| 5422 | } | ||
| 5423 | if (2*ures < ulp) | ||
| 5424 | goto Roundup; | ||
| 5425 | } | ||
| 5426 | --j; | ||
| 5427 | if (i == ilim) { | ||
| 5428 | #ifdef Honor_FLT_ROUNDS | ||
| 5429 | switch(Rounding) { | ||
| 5430 | case 0: goto retc; | ||
| 5431 | case 2: goto Roundup; | ||
| 5432 | } | ||
| 5433 | #endif | ||
| 5434 | hb = 1ull << j; | ||
| 5435 | if (res & hb && (dig & 1 || res & (hb-1))) | ||
| 5436 | goto Roundup; | ||
| 5437 | if (spec_case && res <= ulp && 2*res >= ulp) { | ||
| 5438 | Roundup: | ||
| 5439 | while(*--s == '9') | ||
| 5440 | if (s == buf) { | ||
| 5441 | ++k; | ||
| 5442 | *s++ = '1'; | ||
| 5443 | goto ret1; | ||
| 5444 | } | ||
| 5445 | ++*s++; | ||
| 5446 | goto ret1; | ||
| 5447 | } | ||
| 5448 | goto retc; | ||
| 5449 | } | ||
| 5450 | ++i; | ||
| 5451 | res *= 5; | ||
| 5452 | if (ulpshift) { | ||
| 5453 | ulplo = 5*(ulplo & ulpmask); | ||
| 5454 | ulp = 5*ulp + (ulplo >> ulpshift); | ||
| 5455 | } | ||
| 5456 | else | ||
| 5457 | ulp *= 5; | ||
| 5458 | } | ||
| 5459 | } | ||
| 5460 | toobig: | ||
| 5461 | if (ilim > 28) | ||
| 5462 | goto Fast_failed1; | ||
| 5463 | /* Scale by 10^-k */ | ||
| 5464 | p10 = &pten[342-k]; | ||
| 5465 | tv0 = p10->b2 * dblo; /* rarely matters, but does, e.g., for 9.862818194192001e18 */ | ||
| 5466 | tv1 = p10->b1 * dblo + (tv0 >> 32); | ||
| 5467 | tv2 = p10->b2 * dbhi + (tv1 & 0xffffffffull); | ||
| 5468 | tv3 = p10->b0 * dblo + (tv1>>32) + (tv2>>32); | ||
| 5469 | res3 = p10->b1 * dbhi + (tv3 & 0xffffffffull); | ||
| 5470 | res = p10->b0 * dbhi + (tv3>>32) + (res3>>32); | ||
| 5471 | be += p10->e - 0x3fe; | ||
| 5472 | eulp = j1 = be - 54 + ulpadj; | ||
| 5473 | if (!(res & 0x8000000000000000ull)) { | ||
| 5474 | --be; | ||
| 5475 | res3 <<= 1; | ||
| 5476 | res = (res << 1) | ((res3 & 0x100000000ull) >> 32); | ||
| 5477 | } | ||
| 5478 | res0 = res; /* save for Fast_failed */ | ||
| 5479 | #if !defined(SET_INEXACT) && !defined(NO_DTOA_64) /*{*/ | ||
| 5480 | if (ilim > 19) | ||
| 5481 | goto Fast_failed; | ||
| 5482 | Debug(++dtoa_stats[4]); | ||
| 5483 | assert(be >= 0 && be <= 4); /* be = 0 is rare, but possible, e.g., for 1e20 */ | ||
| 5484 | res >>= 4 - be; | ||
| 5485 | ulp = p10->b0; /* ulp */ | ||
| 5486 | ulp = (ulp << 29) | (p10->b1 >> 3); | ||
| 5487 | /* scaled ulp = ulp * 2^(eulp - 60) */ | ||
| 5488 | /* We maintain 61 bits of the scaled ulp. */ | ||
| 5489 | if (ilim == 0) { | ||
| 5490 | if (!(res & 0x7fffffffffffffeull) | ||
| 5491 | || !((~res) & 0x7fffffffffffffeull)) | ||
| 5492 | goto Fast_failed1; | ||
| 5493 | S = mhi = 0; | ||
| 5494 | if (res >= 0x5000000000000000ull) | ||
| 5495 | goto one_digit; | ||
| 5496 | goto no_digits; | ||
| 5497 | } | ||
| 5498 | rb = 1; /* upper bound on rounding error */ | ||
| 5499 | for(;;++i) { | ||
| 5500 | dig = res >> 60; | ||
| 5501 | *s++ = '0' + dig; | ||
| 5502 | res &= 0xfffffffffffffffull; | ||
| 5503 | if (ilim < 0) { | ||
| 5504 | ures = 0x1000000000000000ull - res; | ||
| 5505 | if (eulp > 0) { | ||
| 5506 | assert(eulp <= 4); | ||
| 5507 | sulp = ulp << (eulp - 1); | ||
| 5508 | if (res <= ures) { | ||
| 5509 | if (res + rb > ures - rb) | ||
| 5510 | goto Fast_failed; | ||
| 5511 | if (res < sulp) | ||
| 5512 | goto retc; | ||
| 5513 | } | ||
| 5514 | else { | ||
| 5515 | if (res - rb <= ures + rb) | ||
| 5516 | goto Fast_failed; | ||
| 5517 | if (ures < sulp) | ||
| 5518 | goto Roundup; | ||
| 5519 | } | ||
| 5520 | } | ||
| 5521 | else { | ||
| 5522 | zb = -(1ull << (eulp + 63)); | ||
| 5523 | if (!(zb & res)) { | ||
| 5524 | sres = res << (1 - eulp); | ||
| 5525 | if (sres < ulp && (!spec_case || 2*sres < ulp)) { | ||
| 5526 | if ((res+rb) << (1 - eulp) >= ulp) | ||
| 5527 | goto Fast_failed; | ||
| 5528 | if (ures < res) { | ||
| 5529 | if (ures + rb >= res - rb) | ||
| 5530 | goto Fast_failed; | ||
| 5531 | goto Roundup; | ||
| 5532 | } | ||
| 5533 | if (ures - rb < res + rb) | ||
| 5534 | goto Fast_failed; | ||
| 5535 | goto retc; | ||
| 5536 | } | ||
| 5537 | } | ||
| 5538 | if (!(zb & ures) && ures << -eulp < ulp) { | ||
| 5539 | if (ures << (1 - eulp) < ulp) | ||
| 5540 | goto Roundup; | ||
| 5541 | goto Fast_failed; | ||
| 5542 | } | ||
| 5543 | } | ||
| 5544 | } | ||
| 5545 | else if (i == ilim) { | ||
| 5546 | ures = 0x1000000000000000ull - res; | ||
| 5547 | if (ures < res) { | ||
| 5548 | if (ures <= rb || res - rb <= ures + rb) { | ||
| 5549 | if (j + k >= 0 && k >= 0 && k <= 27) | ||
| 5550 | goto use_exact1; | ||
| 5551 | goto Fast_failed; | ||
| 5552 | } | ||
| 5553 | #ifdef Honor_FLT_ROUNDS | ||
| 5554 | if (Rounding == 0) | ||
| 5555 | goto retc; | ||
| 5556 | #endif | ||
| 5557 | goto Roundup; | ||
| 5558 | } | ||
| 5559 | if (res <= rb || ures - rb <= res + rb) { | ||
| 5560 | if (j + k >= 0 && k >= 0 && k <= 27) { | ||
| 5561 | use_exact1: | ||
| 5562 | s = buf; | ||
| 5563 | i = 1; | ||
| 5564 | goto use_exact; | ||
| 5565 | } | ||
| 5566 | goto Fast_failed; | ||
| 5567 | } | ||
| 5568 | #ifdef Honor_FLT_ROUNDS | ||
| 5569 | if (Rounding == 2) | ||
| 5570 | goto Roundup; | ||
| 5571 | #endif | ||
| 5572 | goto retc; | ||
| 5573 | } | ||
| 5574 | rb *= 10; | ||
| 5575 | if (rb >= 0x1000000000000000ull) | ||
| 5576 | goto Fast_failed; | ||
| 5577 | res *= 10; | ||
| 5578 | ulp *= 5; | ||
| 5579 | if (ulp & 0x8000000000000000ull) { | ||
| 5580 | eulp += 4; | ||
| 5581 | ulp >>= 3; | ||
| 5582 | } | ||
| 5583 | else { | ||
| 5584 | eulp += 3; | ||
| 5585 | ulp >>= 2; | ||
| 5586 | } | ||
| 5587 | } | ||
| 5588 | #endif /*}*/ | ||
| 5589 | #ifndef NO_BF96 | ||
| 5590 | Fast_failed: | ||
| 5591 | #endif | ||
| 5592 | Debug(++dtoa_stats[5]); | ||
| 5593 | s = buf; | ||
| 5594 | i = 4 - be; | ||
| 5595 | res = res0 >> i; | ||
| 5596 | reslo = 0xffffffffull & res3; | ||
| 5597 | if (i) | ||
| 5598 | reslo = (res0 << (64 - i)) >> 32 | (reslo >> i); | ||
| 5599 | rb = 0; | ||
| 5600 | rblo = 4; /* roundoff bound */ | ||
| 5601 | ulp = p10->b0; /* ulp */ | ||
| 5602 | ulp = (ulp << 29) | (p10->b1 >> 3); | ||
| 5603 | eulp = j1; | ||
| 5604 | for(i = 1;;++i) { | ||
| 5605 | dig = res >> 60; | ||
| 5606 | *s++ = '0' + dig; | ||
| 5607 | res &= 0xfffffffffffffffull; | ||
| 5608 | #ifdef SET_INEXACT | ||
| 5609 | if (!res && !reslo) { | ||
| 5610 | if (!(res3 & 0xffffffffull)) { | ||
| 5611 | inexact = 0; | ||
| 5612 | oldinexact = 1; | ||
| 5613 | } | ||
| 5614 | goto retc; | ||
| 5615 | } | ||
| 5616 | #endif | ||
| 5617 | if (ilim < 0) { | ||
| 5618 | ures = 0x1000000000000000ull - res; | ||
| 5619 | ureslo = 0; | ||
| 5620 | if (reslo) { | ||
| 5621 | ureslo = 0x100000000ull - reslo; | ||
| 5622 | --ures; | ||
| 5623 | } | ||
| 5624 | if (eulp > 0) { | ||
| 5625 | assert(eulp <= 4); | ||
| 5626 | sulp = (ulp << (eulp - 1)) - rb; | ||
| 5627 | if (res <= ures) { | ||
| 5628 | if (res < sulp) { | ||
| 5629 | if (res+rb < ures-rb) | ||
| 5630 | goto retc; | ||
| 5631 | } | ||
| 5632 | } | ||
| 5633 | else if (ures < sulp) { | ||
| 5634 | if (res-rb > ures+rb) | ||
| 5635 | goto Roundup; | ||
| 5636 | } | ||
| 5637 | goto Fast_failed1; | ||
| 5638 | } | ||
| 5639 | else { | ||
| 5640 | zb = -(1ull << (eulp + 60)); | ||
| 5641 | if (!(zb & (res + rb))) { | ||
| 5642 | sres = (res - rb) << (1 - eulp); | ||
| 5643 | if (sres < ulp && (!spec_case || 2*sres < ulp)) { | ||
| 5644 | sres = res << (1 - eulp); | ||
| 5645 | if ((j = eulp + 31) > 0) | ||
| 5646 | sres += (rblo + reslo) >> j; | ||
| 5647 | else | ||
| 5648 | sres += (rblo + reslo) << -j; | ||
| 5649 | if (sres + (rb << (1 - eulp)) >= ulp) | ||
| 5650 | goto Fast_failed1; | ||
| 5651 | if (sres >= ulp) | ||
| 5652 | goto more96; | ||
| 5653 | if (ures < res | ||
| 5654 | || (ures == res && ureslo < reslo)) { | ||
| 5655 | if (ures + rb >= res - rb) | ||
| 5656 | goto Fast_failed1; | ||
| 5657 | goto Roundup; | ||
| 5658 | } | ||
| 5659 | if (ures - rb <= res + rb) | ||
| 5660 | goto Fast_failed1; | ||
| 5661 | goto retc; | ||
| 5662 | } | ||
| 5663 | } | ||
| 5664 | if (!(zb & ures) && (ures-rb) << (1 - eulp) < ulp) { | ||
| 5665 | if ((ures + rb) << (1 - eulp) < ulp) | ||
| 5666 | goto Roundup; | ||
| 5667 | goto Fast_failed1; | ||
| 5668 | } | ||
| 5669 | } | ||
| 5670 | } | ||
| 5671 | else if (i == ilim) { | ||
| 5672 | ures = 0x1000000000000000ull - res; | ||
| 5673 | sres = ureslo = 0; | ||
| 5674 | if (reslo) { | ||
| 5675 | ureslo = 0x100000000ull - reslo; | ||
| 5676 | --ures; | ||
| 5677 | sres = (reslo + rblo) >> 31; | ||
| 5678 | } | ||
| 5679 | sres += 2*rb; | ||
| 5680 | if (ures <= res) { | ||
| 5681 | if (ures <=sres || res - ures <= sres) | ||
| 5682 | goto Fast_failed1; | ||
| 5683 | #ifdef Honor_FLT_ROUNDS | ||
| 5684 | if (Rounding == 0) | ||
| 5685 | goto retc; | ||
| 5686 | #endif | ||
| 5687 | goto Roundup; | ||
| 5688 | } | ||
| 5689 | if (res <= sres || ures - res <= sres) | ||
| 5690 | goto Fast_failed1; | ||
| 5691 | #ifdef Honor_FLT_ROUNDS | ||
| 5692 | if (Rounding == 2) | ||
| 5693 | goto Roundup; | ||
| 5694 | #endif | ||
| 5695 | goto retc; | ||
| 5696 | } | ||
| 5697 | more96: | ||
| 5698 | rblo *= 10; | ||
| 5699 | rb = 10*rb + (rblo >> 32); | ||
| 5700 | rblo &= 0xffffffffull; | ||
| 5701 | if (rb >= 0x1000000000000000ull) | ||
| 5702 | goto Fast_failed1; | ||
| 5703 | reslo *= 10; | ||
| 5704 | res = 10*res + (reslo >> 32); | ||
| 5705 | reslo &= 0xffffffffull; | ||
| 5706 | ulp *= 5; | ||
| 5707 | if (ulp & 0x8000000000000000ull) { | ||
| 5708 | eulp += 4; | ||
| 5709 | ulp >>= 3; | ||
| 5710 | } | ||
| 5711 | else { | ||
| 5712 | eulp += 3; | ||
| 5713 | ulp >>= 2; | ||
| 5714 | } | ||
| 5715 | } | ||
| 5716 | Fast_failed1: | ||
| 5717 | Debug(++dtoa_stats[6]); | ||
| 5718 | S = mhi = mlo = 0; | ||
| 5719 | #ifdef USE_BF96 | ||
| 5720 | b = d2b(&u, &be, &bbits MTb); | ||
| 5721 | #endif | ||
| 5722 | s = buf; | ||
| 5723 | i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); | ||
| 5724 | i -= Bias; | ||
| 5725 | if (ulpadj) | ||
| 5726 | i -= ulpadj - 1; | ||
| 5727 | j = bbits - i - 1; | ||
| 5728 | if (j >= 0) { | ||
| 5729 | b2 = 0; | ||
| 5730 | s2 = j; | ||
| 5731 | } | ||
| 5732 | else { | ||
| 5733 | b2 = -j; | ||
| 5734 | s2 = 0; | ||
| 5735 | } | ||
| 5736 | if (k >= 0) { | ||
| 5737 | b5 = 0; | ||
| 5738 | s5 = k; | ||
| 5739 | s2 += k; | ||
| 5740 | } | ||
| 5741 | else { | ||
| 5742 | b2 -= k; | ||
| 5743 | b5 = -k; | ||
| 5744 | s5 = 0; | ||
| 5745 | } | ||
| 5746 | #endif /*}*/ | ||
| 3910 | 5747 | ||
| 3911 | #ifdef Honor_FLT_ROUNDS | 5748 | #ifdef Honor_FLT_ROUNDS |
| 3912 | if (mode > 1 && Rounding != 1) | 5749 | if (mode > 1 && Rounding != 1) |
| 3913 | leftright = 0; | 5750 | leftright = 0; |
| 3914 | #endif | 5751 | #endif |
| 3915 | 5752 | ||
| 5753 | #ifndef USE_BF96 /*{*/ | ||
| 3916 | if (ilim >= 0 && ilim <= Quick_max && try_quick) { | 5754 | if (ilim >= 0 && ilim <= Quick_max && try_quick) { |
| 3917 | 5755 | ||
| 3918 | /* Try to get by with floating-point arithmetic. */ | 5756 | /* Try to get by with floating-point arithmetic. */ |
| 3919 | 5757 | ||
| 3920 | i = 0; | 5758 | i = 0; |
| 3921 | dval(&d2) = dval(&u); | 5759 | dval(&d2) = dval(&u); |
| 3922 | k0 = k; | 5760 | j1 = -(k0 = k); |
| 3923 | ilim0 = ilim; | 5761 | ilim0 = ilim; |
| 3924 | ieps = 2; /* conservative */ | 5762 | ieps = 2; /* conservative */ |
| 3925 | if (k > 0) { | 5763 | if (k > 0) { |
| @@ -3938,7 +5776,7 @@ dtoa | |||
| 3938 | } | 5776 | } |
| 3939 | dval(&u) /= ds; | 5777 | dval(&u) /= ds; |
| 3940 | } | 5778 | } |
| 3941 | else if ((j1 = -k)) { | 5779 | else if (j1 > 0) { |
| 3942 | dval(&u) *= tens[j1 & 0xf]; | 5780 | dval(&u) *= tens[j1 & 0xf]; |
| 3943 | for(j = j1 >> 4; j; j >>= 1, i++) | 5781 | for(j = j1 >> 4; j; j >>= 1, i++) |
| 3944 | if (j & 1) { | 5782 | if (j & 1) { |
| @@ -3972,7 +5810,7 @@ dtoa | |||
| 3972 | */ | 5810 | */ |
| 3973 | dval(&eps) = 0.5/tens[ilim-1] - dval(&eps); | 5811 | dval(&eps) = 0.5/tens[ilim-1] - dval(&eps); |
| 3974 | #ifdef IEEE_Arith | 5812 | #ifdef IEEE_Arith |
| 3975 | if (k0 < 0 && j1 >= 307) { | 5813 | if (j1 >= 307) { |
| 3976 | eps1.d = 1.01e256; /* 1.01 allows roundoff in the next few lines */ | 5814 | eps1.d = 1.01e256; /* 1.01 allows roundoff in the next few lines */ |
| 3977 | word0(&eps1) -= Exp_msk1 * (Bias+P-1); | 5815 | word0(&eps1) -= Exp_msk1 * (Bias+P-1); |
| 3978 | dval(&eps1) *= tens[j1 & 0xf]; | 5816 | dval(&eps1) *= tens[j1 & 0xf]; |
| @@ -3981,6 +5819,12 @@ dtoa | |||
| 3981 | dval(&eps1) *= bigtens[i]; | 5819 | dval(&eps1) *= bigtens[i]; |
| 3982 | if (eps.d < eps1.d) | 5820 | if (eps.d < eps1.d) |
| 3983 | eps.d = eps1.d; | 5821 | eps.d = eps1.d; |
| 5822 | if (10. - u.d < 10.*eps.d && eps.d < 1.) { | ||
| 5823 | /* eps.d < 1. excludes trouble with the tiniest denormal */ | ||
| 5824 | *s++ = '1'; | ||
| 5825 | ++k; | ||
| 5826 | goto ret1; | ||
| 5827 | } | ||
| 3984 | } | 5828 | } |
| 3985 | #endif | 5829 | #endif |
| 3986 | for(i = 0;;) { | 5830 | for(i = 0;;) { |
| @@ -3990,7 +5834,7 @@ dtoa | |||
| 3990 | if (1. - dval(&u) < dval(&eps)) | 5834 | if (1. - dval(&u) < dval(&eps)) |
| 3991 | goto bump_up; | 5835 | goto bump_up; |
| 3992 | if (dval(&u) < dval(&eps)) | 5836 | if (dval(&u) < dval(&eps)) |
| 3993 | goto ret1; | 5837 | goto retc; |
| 3994 | if (++i >= ilim) | 5838 | if (++i >= ilim) |
| 3995 | break; | 5839 | break; |
| 3996 | dval(&eps) *= 10.; | 5840 | dval(&eps) *= 10.; |
| @@ -4009,11 +5853,8 @@ dtoa | |||
| 4009 | if (i == ilim) { | 5853 | if (i == ilim) { |
| 4010 | if (dval(&u) > 0.5 + dval(&eps)) | 5854 | if (dval(&u) > 0.5 + dval(&eps)) |
| 4011 | goto bump_up; | 5855 | goto bump_up; |
| 4012 | else if (dval(&u) < 0.5 - dval(&eps)) { | 5856 | else if (dval(&u) < 0.5 - dval(&eps)) |
| 4013 | while(*--s == '0'); | 5857 | goto retc; |
| 4014 | s++; | ||
| 4015 | goto ret1; | ||
| 4016 | } | ||
| 4017 | break; | 5858 | break; |
| 4018 | } | 5859 | } |
| 4019 | } | 5860 | } |
| @@ -4021,7 +5862,7 @@ dtoa | |||
| 4021 | } | 5862 | } |
| 4022 | #endif | 5863 | #endif |
| 4023 | fast_failed: | 5864 | fast_failed: |
| 4024 | s = s0; | 5865 | s = buf; |
| 4025 | dval(&u) = dval(&d2); | 5866 | dval(&u) = dval(&d2); |
| 4026 | k = k0; | 5867 | k = k0; |
| 4027 | ilim = ilim0; | 5868 | ilim = ilim0; |
| @@ -4059,7 +5900,7 @@ dtoa | |||
| 4059 | #ifdef Honor_FLT_ROUNDS | 5900 | #ifdef Honor_FLT_ROUNDS |
| 4060 | if (mode > 1) | 5901 | if (mode > 1) |
| 4061 | switch(Rounding) { | 5902 | switch(Rounding) { |
| 4062 | case 0: goto ret1; | 5903 | case 0: goto retc; |
| 4063 | case 2: goto bump_up; | 5904 | case 2: goto bump_up; |
| 4064 | } | 5905 | } |
| 4065 | #endif | 5906 | #endif |
| @@ -4072,7 +5913,7 @@ dtoa | |||
| 4072 | { | 5913 | { |
| 4073 | bump_up: | 5914 | bump_up: |
| 4074 | while(*--s == '9') | 5915 | while(*--s == '9') |
| 4075 | if (s == s0) { | 5916 | if (s == buf) { |
| 4076 | k++; | 5917 | k++; |
| 4077 | *s = '0'; | 5918 | *s = '0'; |
| 4078 | break; | 5919 | break; |
| @@ -4082,9 +5923,10 @@ dtoa | |||
| 4082 | break; | 5923 | break; |
| 4083 | } | 5924 | } |
| 4084 | } | 5925 | } |
| 4085 | goto ret1; | 5926 | goto retc; |
| 4086 | } | 5927 | } |
| 4087 | 5928 | ||
| 5929 | #endif /*}*/ | ||
| 4088 | m2 = b2; | 5930 | m2 = b2; |
| 4089 | m5 = b5; | 5931 | m5 = b5; |
| 4090 | mhi = mlo = 0; | 5932 | mhi = mlo = 0; |
| @@ -4100,7 +5942,7 @@ dtoa | |||
| 4100 | #endif | 5942 | #endif |
| 4101 | b2 += i; | 5943 | b2 += i; |
| 4102 | s2 += i; | 5944 | s2 += i; |
| 4103 | mhi = i2b(1); | 5945 | mhi = i2b(1 MTb); |
| 4104 | } | 5946 | } |
| 4105 | if (m2 > 0 && s2 > 0) { | 5947 | if (m2 > 0 && s2 > 0) { |
| 4106 | i = m2 < s2 ? m2 : s2; | 5948 | i = m2 < s2 ? m2 : s2; |
| @@ -4111,39 +5953,24 @@ dtoa | |||
| 4111 | if (b5 > 0) { | 5953 | if (b5 > 0) { |
| 4112 | if (leftright) { | 5954 | if (leftright) { |
| 4113 | if (m5 > 0) { | 5955 | if (m5 > 0) { |
| 4114 | mhi = pow5mult(mhi, m5); | 5956 | mhi = pow5mult(mhi, m5 MTb); |
| 4115 | b1 = mult(mhi, b); | 5957 | b1 = mult(mhi, b MTb); |
| 4116 | Bfree(b); | 5958 | Bfree(b MTb); |
| 4117 | b = b1; | 5959 | b = b1; |
| 4118 | } | 5960 | } |
| 4119 | if ((j = b5 - m5)) | 5961 | if ((j = b5 - m5)) |
| 4120 | b = pow5mult(b, j); | 5962 | b = pow5mult(b, j MTb); |
| 4121 | } | 5963 | } |
| 4122 | else | 5964 | else |
| 4123 | b = pow5mult(b, b5); | 5965 | b = pow5mult(b, b5 MTb); |
| 4124 | } | 5966 | } |
| 4125 | S = i2b(1); | 5967 | S = i2b(1 MTb); |
| 4126 | if (s5 > 0) | 5968 | if (s5 > 0) |
| 4127 | S = pow5mult(S, s5); | 5969 | S = pow5mult(S, s5 MTb); |
| 4128 | 5970 | ||
| 4129 | /* Check for special case that d is a normalized power of 2. */ | 5971 | if (spec_case) { |
| 4130 | 5972 | b2 += Log2P; | |
| 4131 | spec_case = 0; | 5973 | s2 += Log2P; |
| 4132 | if ((mode < 2 || leftright) | ||
| 4133 | #ifdef Honor_FLT_ROUNDS | ||
| 4134 | && Rounding == 1 | ||
| 4135 | #endif | ||
| 4136 | ) { | ||
| 4137 | if (!word1(&u) && !(word0(&u) & Bndry_mask) | ||
| 4138 | #ifndef Sudden_Underflow | ||
| 4139 | && word0(&u) & (Exp_mask & ~Exp_msk1) | ||
| 4140 | #endif | ||
| 4141 | ) { | ||
| 4142 | /* The special case */ | ||
| 4143 | b2 += Log2P; | ||
| 4144 | s2 += Log2P; | ||
| 4145 | spec_case = 1; | ||
| 4146 | } | ||
| 4147 | } | 5974 | } |
| 4148 | 5975 | ||
| 4149 | /* Arrange for convenient computation of quotients: | 5976 | /* Arrange for convenient computation of quotients: |
| @@ -4158,20 +5985,22 @@ dtoa | |||
| 4158 | m2 += i; | 5985 | m2 += i; |
| 4159 | s2 += i; | 5986 | s2 += i; |
| 4160 | if (b2 > 0) | 5987 | if (b2 > 0) |
| 4161 | b = lshift(b, b2); | 5988 | b = lshift(b, b2 MTb); |
| 4162 | if (s2 > 0) | 5989 | if (s2 > 0) |
| 4163 | S = lshift(S, s2); | 5990 | S = lshift(S, s2 MTb); |
| 5991 | #ifndef USE_BF96 | ||
| 4164 | if (k_check) { | 5992 | if (k_check) { |
| 4165 | if (cmp(b,S) < 0) { | 5993 | if (cmp(b,S) < 0) { |
| 4166 | k--; | 5994 | k--; |
| 4167 | b = multadd(b, 10, 0); /* we botched the k estimate */ | 5995 | b = multadd(b, 10, 0 MTb); /* we botched the k estimate */ |
| 4168 | if (leftright) | 5996 | if (leftright) |
| 4169 | mhi = multadd(mhi, 10, 0); | 5997 | mhi = multadd(mhi, 10, 0 MTb); |
| 4170 | ilim = ilim1; | 5998 | ilim = ilim1; |
| 4171 | } | 5999 | } |
| 4172 | } | 6000 | } |
| 6001 | #endif | ||
| 4173 | if (ilim <= 0 && (mode == 3 || mode == 5)) { | 6002 | if (ilim <= 0 && (mode == 3 || mode == 5)) { |
| 4174 | if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) { | 6003 | if (ilim < 0 || cmp(b,S = multadd(S,5,0 MTb)) <= 0) { |
| 4175 | /* no digits, fcvt style */ | 6004 | /* no digits, fcvt style */ |
| 4176 | no_digits: | 6005 | no_digits: |
| 4177 | k = -1 - ndigits; | 6006 | k = -1 - ndigits; |
| @@ -4179,12 +6008,12 @@ dtoa | |||
| 4179 | } | 6008 | } |
| 4180 | one_digit: | 6009 | one_digit: |
| 4181 | *s++ = '1'; | 6010 | *s++ = '1'; |
| 4182 | k++; | 6011 | ++k; |
| 4183 | goto ret; | 6012 | goto ret; |
| 4184 | } | 6013 | } |
| 4185 | if (leftright) { | 6014 | if (leftright) { |
| 4186 | if (m2 > 0) | 6015 | if (m2 > 0) |
| 4187 | mhi = lshift(mhi, m2); | 6016 | mhi = lshift(mhi, m2 MTb); |
| 4188 | 6017 | ||
| 4189 | /* Compute mlo -- check for special case | 6018 | /* Compute mlo -- check for special case |
| 4190 | * that d is a normalized power of 2. | 6019 | * that d is a normalized power of 2. |
| @@ -4192,9 +6021,9 @@ dtoa | |||
| 4192 | 6021 | ||
| 4193 | mlo = mhi; | 6022 | mlo = mhi; |
| 4194 | if (spec_case) { | 6023 | if (spec_case) { |
| 4195 | mhi = Balloc(mhi->k); | 6024 | mhi = Balloc(mhi->k MTb); |
| 4196 | Bcopy(mhi, mlo); | 6025 | Bcopy(mhi, mlo); |
| 4197 | mhi = lshift(mhi, Log2P); | 6026 | mhi = lshift(mhi, Log2P MTb); |
| 4198 | } | 6027 | } |
| 4199 | 6028 | ||
| 4200 | for(i = 1;;i++) { | 6029 | for(i = 1;;i++) { |
| @@ -4203,13 +6032,13 @@ dtoa | |||
| 4203 | * that will round to d? | 6032 | * that will round to d? |
| 4204 | */ | 6033 | */ |
| 4205 | j = cmp(b, mlo); | 6034 | j = cmp(b, mlo); |
| 4206 | delta = diff(S, mhi); | 6035 | delta = diff(S, mhi MTb); |
| 4207 | j1 = delta->sign ? 1 : cmp(b, delta); | 6036 | j1 = delta->sign ? 1 : cmp(b, delta); |
| 4208 | Bfree(delta); | 6037 | Bfree(delta MTb); |
| 4209 | #ifndef ROUND_BIASED | 6038 | #ifndef ROUND_BIASED |
| 4210 | if (j1 == 0 && mode != 1 && !(word1(&u) & 1) | 6039 | if (j1 == 0 && mode != 1 && !(word1(&u) & 1) |
| 4211 | #ifdef Honor_FLT_ROUNDS | 6040 | #ifdef Honor_FLT_ROUNDS |
| 4212 | && Rounding >= 1 | 6041 | && (mode <= 1 || Rounding >= 1) |
| 4213 | #endif | 6042 | #endif |
| 4214 | ) { | 6043 | ) { |
| 4215 | if (dig == '9') | 6044 | if (dig == '9') |
| @@ -4243,7 +6072,7 @@ dtoa | |||
| 4243 | } | 6072 | } |
| 4244 | #endif /*Honor_FLT_ROUNDS*/ | 6073 | #endif /*Honor_FLT_ROUNDS*/ |
| 4245 | if (j1 > 0) { | 6074 | if (j1 > 0) { |
| 4246 | b = lshift(b, 1); | 6075 | b = lshift(b, 1 MTb); |
| 4247 | j1 = cmp(b, S); | 6076 | j1 = cmp(b, S); |
| 4248 | #ifdef ROUND_BIASED | 6077 | #ifdef ROUND_BIASED |
| 4249 | if (j1 >= 0 /*)*/ | 6078 | if (j1 >= 0 /*)*/ |
| @@ -4259,7 +6088,7 @@ dtoa | |||
| 4259 | } | 6088 | } |
| 4260 | if (j1 > 0) { | 6089 | if (j1 > 0) { |
| 4261 | #ifdef Honor_FLT_ROUNDS | 6090 | #ifdef Honor_FLT_ROUNDS |
| 4262 | if (!Rounding) | 6091 | if (!Rounding && mode > 1) |
| 4263 | goto accept_dig; | 6092 | goto accept_dig; |
| 4264 | #endif | 6093 | #endif |
| 4265 | if (dig == '9') { /* possible if i == 1 */ | 6094 | if (dig == '9') { /* possible if i == 1 */ |
| @@ -4276,18 +6105,19 @@ dtoa | |||
| 4276 | *s++ = dig; | 6105 | *s++ = dig; |
| 4277 | if (i == ilim) | 6106 | if (i == ilim) |
| 4278 | break; | 6107 | break; |
| 4279 | b = multadd(b, 10, 0); | 6108 | b = multadd(b, 10, 0 MTb); |
| 4280 | if (mlo == mhi) | 6109 | if (mlo == mhi) |
| 4281 | mlo = mhi = multadd(mhi, 10, 0); | 6110 | mlo = mhi = multadd(mhi, 10, 0 MTb); |
| 4282 | else { | 6111 | else { |
| 4283 | mlo = multadd(mlo, 10, 0); | 6112 | mlo = multadd(mlo, 10, 0 MTb); |
| 4284 | mhi = multadd(mhi, 10, 0); | 6113 | mhi = multadd(mhi, 10, 0 MTb); |
| 4285 | } | 6114 | } |
| 4286 | } | 6115 | } |
| 4287 | } | 6116 | } |
| 4288 | else | 6117 | else |
| 4289 | for(i = 1;; i++) { | 6118 | for(i = 1;; i++) { |
| 4290 | *s++ = dig = quorem(b,S) + '0'; | 6119 | dig = quorem(b,S) + '0'; |
| 6120 | *s++ = dig; | ||
| 4291 | if (!b->x[0] && b->wds <= 1) { | 6121 | if (!b->x[0] && b->wds <= 1) { |
| 4292 | #ifdef SET_INEXACT | 6122 | #ifdef SET_INEXACT |
| 4293 | inexact = 0; | 6123 | inexact = 0; |
| @@ -4296,18 +6126,19 @@ dtoa | |||
| 4296 | } | 6126 | } |
| 4297 | if (i >= ilim) | 6127 | if (i >= ilim) |
| 4298 | break; | 6128 | break; |
| 4299 | b = multadd(b, 10, 0); | 6129 | b = multadd(b, 10, 0 MTb); |
| 4300 | } | 6130 | } |
| 4301 | 6131 | ||
| 4302 | /* Round off last digit */ | 6132 | /* Round off last digit */ |
| 4303 | 6133 | ||
| 4304 | #ifdef Honor_FLT_ROUNDS | 6134 | #ifdef Honor_FLT_ROUNDS |
| 4305 | switch(Rounding) { | 6135 | if (mode > 1) |
| 4306 | case 0: goto trimzeros; | 6136 | switch(Rounding) { |
| 4307 | case 2: goto roundoff; | 6137 | case 0: goto ret; |
| 4308 | } | 6138 | case 2: goto roundoff; |
| 6139 | } | ||
| 4309 | #endif | 6140 | #endif |
| 4310 | b = lshift(b, 1); | 6141 | b = lshift(b, 1 MTb); |
| 4311 | j = cmp(b, S); | 6142 | j = cmp(b, S); |
| 4312 | #ifdef ROUND_BIASED | 6143 | #ifdef ROUND_BIASED |
| 4313 | if (j >= 0) | 6144 | if (j >= 0) |
| @@ -4317,28 +6148,30 @@ dtoa | |||
| 4317 | { | 6148 | { |
| 4318 | roundoff: | 6149 | roundoff: |
| 4319 | while(*--s == '9') | 6150 | while(*--s == '9') |
| 4320 | if (s == s0) { | 6151 | if (s == buf) { |
| 4321 | k++; | 6152 | k++; |
| 4322 | *s++ = '1'; | 6153 | *s++ = '1'; |
| 4323 | goto ret; | 6154 | goto ret; |
| 4324 | } | 6155 | } |
| 4325 | ++*s++; | 6156 | ++*s++; |
| 4326 | } | 6157 | } |
| 4327 | else { | ||
| 4328 | #ifdef Honor_FLT_ROUNDS | ||
| 4329 | trimzeros: | ||
| 4330 | #endif | ||
| 4331 | while(*--s == '0'); | ||
| 4332 | s++; | ||
| 4333 | } | ||
| 4334 | ret: | 6158 | ret: |
| 4335 | Bfree(S); | 6159 | Bfree(S MTb); |
| 4336 | if (mhi) { | 6160 | if (mhi) { |
| 4337 | if (mlo && mlo != mhi) | 6161 | if (mlo && mlo != mhi) |
| 4338 | Bfree(mlo); | 6162 | Bfree(mlo MTb); |
| 4339 | Bfree(mhi); | 6163 | Bfree(mhi MTb); |
| 4340 | } | 6164 | } |
| 6165 | retc: | ||
| 6166 | while(s > buf && s[-1] == '0') | ||
| 6167 | --s; | ||
| 4341 | ret1: | 6168 | ret1: |
| 6169 | if (b) | ||
| 6170 | Bfree(b MTb); | ||
| 6171 | *s = 0; | ||
| 6172 | *decpt = k + 1; | ||
| 6173 | if (rve) | ||
| 6174 | *rve = s; | ||
| 4342 | #ifdef SET_INEXACT | 6175 | #ifdef SET_INEXACT |
| 4343 | if (inexact) { | 6176 | if (inexact) { |
| 4344 | if (!oldinexact) { | 6177 | if (!oldinexact) { |
| @@ -4350,13 +6183,23 @@ dtoa | |||
| 4350 | else if (!oldinexact) | 6183 | else if (!oldinexact) |
| 4351 | clear_inexact(); | 6184 | clear_inexact(); |
| 4352 | #endif | 6185 | #endif |
| 4353 | Bfree(b); | 6186 | return buf; |
| 4354 | *s = 0; | 6187 | } |
| 4355 | *decpt = k + 1; | 6188 | |
| 4356 | if (rve) | 6189 | char * |
| 4357 | *rve = s; | 6190 | dtoa(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve) |
| 4358 | return s0; | 6191 | { |
| 6192 | /* Sufficient space is allocated to the return value | ||
| 6193 | to hold the suppressed trailing zeros. | ||
| 6194 | See dtoa_r() above for details on the other arguments. | ||
| 6195 | */ | ||
| 6196 | #ifndef MULTIPLE_THREADS | ||
| 6197 | if (dtoa_result) | ||
| 6198 | freedtoa(dtoa_result); | ||
| 6199 | #endif | ||
| 6200 | return dtoa_r(dd, mode, ndigits, decpt, sign, rve, 0, 0); | ||
| 4359 | } | 6201 | } |
| 6202 | |||
| 4360 | #ifdef __cplusplus | 6203 | #ifdef __cplusplus |
| 4361 | } | 6204 | } |
| 4362 | #endif | 6205 | #endif |
diff --git a/dtoa_config.h b/dtoa_config.h index 380e83b..c168e28 100644 --- a/dtoa_config.h +++ b/dtoa_config.h | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | #define IEEE_8087 | 24 | #define IEEE_8087 |
| 25 | #endif | 25 | #endif |
| 26 | 26 | ||
| 27 | #define MALLOC(n) xmalloc(n) | 27 | #define MALLOC xmalloc |
| 28 | 28 | ||
| 29 | static void *xmalloc(size_t size) | 29 | static void *xmalloc(size_t size) |
| 30 | { | 30 | { |
| @@ -50,6 +50,10 @@ static pthread_mutex_t private_dtoa_lock[2] = { | |||
| 50 | PTHREAD_MUTEX_INITIALIZER | 50 | PTHREAD_MUTEX_INITIALIZER |
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | #define dtoa_get_threadno pthread_self | ||
| 54 | void | ||
| 55 | set_max_dtoa_threads(unsigned int n); | ||
| 56 | |||
| 53 | #define ACQUIRE_DTOA_LOCK(n) do { \ | 57 | #define ACQUIRE_DTOA_LOCK(n) do { \ |
| 54 | int r = pthread_mutex_lock(&private_dtoa_lock[n]); \ | 58 | int r = pthread_mutex_lock(&private_dtoa_lock[n]); \ |
| 55 | if (r) { \ | 59 | if (r) { \ |
| @@ -7,10 +7,20 @@ | |||
| 7 | # define FPCONV_G_FMT_BUFSIZE 32 | 7 | # define FPCONV_G_FMT_BUFSIZE 32 |
| 8 | 8 | ||
| 9 | #ifdef USE_INTERNAL_FPCONV | 9 | #ifdef USE_INTERNAL_FPCONV |
| 10 | static inline void fpconv_init(void) | 10 | #ifdef MULTIPLE_THREADS |
| 11 | #include "dtoa_config.h" | ||
| 12 | #include <unistd.h> | ||
| 13 | static inline void fpconv_init() | ||
| 14 | { | ||
| 15 | // Add one to try and avoid core id multiplier alignment | ||
| 16 | set_max_dtoa_threads((sysconf(_SC_NPROCESSORS_CONF) + 1) * 3); | ||
| 17 | } | ||
| 18 | #else | ||
| 19 | static inline void fpconv_init() | ||
| 11 | { | 20 | { |
| 12 | /* Do nothing - not required */ | 21 | /* Do nothing - not required */ |
| 13 | } | 22 | } |
| 23 | #endif | ||
| 14 | #else | 24 | #else |
| 15 | extern void fpconv_init(void); | 25 | extern void fpconv_init(void); |
| 16 | #endif | 26 | #endif |
diff --git a/runtests.sh b/runtests.sh index fe606fa..1c51236 100755 --- a/runtests.sh +++ b/runtests.sh | |||
| @@ -67,6 +67,16 @@ if [ -z "$SKIP_CMAKE" ]; then | |||
| 67 | cp -r lua/cjson build/cjson.so tests | 67 | cp -r lua/cjson build/cjson.so tests |
| 68 | do_tests | 68 | do_tests |
| 69 | rm -rf build tests/cjson{,.so} | 69 | rm -rf build tests/cjson{,.so} |
| 70 | |||
| 71 | echo "===== Testing Cmake fpconv build =====" | ||
| 72 | mkdir build | ||
| 73 | cd build | ||
| 74 | cmake -DUSE_INTERNAL_FPCONV=1 .. | ||
| 75 | make | ||
| 76 | cd .. | ||
| 77 | cp -r lua/cjson build/cjson.so tests | ||
| 78 | do_tests | ||
| 79 | rm -rf build tests/cjson{,.so} | ||
| 70 | else | 80 | else |
| 71 | echo "===== Skipping Cmake build =====" | 81 | echo "===== Skipping Cmake build =====" |
| 72 | fi | 82 | fi |
