Sun Jun 30 13:48:26 EDT 1991: dtoa.c: adjust dtoa to allow negative ndigits for modes 3,5,7,9 (fixed-point mode); fix rounding bug in these modes when the input d (to be converted) satisfies 10^-(ndigits+1) <= |d| < 10^-ndigits , i.e., when the result, before rounding, would be empty but might round to one digit. Adjust the decpt returned in these modes when the result is empty (i.e., when |d| <= 5 * 10^-ndigits). Tue Jul 2 21:44:00 EDT 1991 Correct an inefficiency introduced 2 days ago in dtoa's handling of integers in modes 0, 1. Mon Sep 9 23:29:38 EDT 1991 dtoa.c: remove superfluous declaration of size_t. Sun Oct 6 15:34:15 EDT 1991 dtoa.c: fix another bug in modes 3,5,7,9 when the result, before rounding, would be empty, but rounds to one digit: *decpt was low by one. Sat Jan 18 12:30:04 EST 1992 dtoa.c: add some #ifdef KR_headers lines relevant only if IBM is defined; for input decimal strings representing numbers too large, have strtod return HUGE_VAL only if __STDC__ is defined; otherwise have it return +-Infinity for IEEE arithmetic, +- the largest machine number for IBM and VAX arithmetic. (If __STDC__ is not defined, HUGE_VAL may not be defined either, or it may be wrong.) Mon Apr 27 23:13:43 EDT 1992 dtoa.c: tweak strtod (one-line addition) so the end-pointer = start pointer when the input has, e.g., only white space. Thu May 7 18:04:46 EDT 1992 dtoa.c: adjust treatment of exponent field (in strtod) to behave reasonably with huge numbers and 16-bit ints. Fri Jun 19 08:29:02 EDT 1992 dtoa.c: fix a botch in placement of #ifdef __cplusplus (which only matters if you're using a C++ compiler). Wed Oct 21 11:23:07 EDT 1992 dtoa.c: add #ifdef Bad_float_h lines for systems with missing or inferior float.h . Thu Apr 22 07:54:48 EDT 1993 dtoa.c: change < to <= in line 2059: < for(result_k = 0; sizeof(Bigint) - sizeof(unsigned long) + j < i; --- > for(result_k = 0; sizeof(Bigint) - sizeof(unsigned long) + j <= i; With 32-bit ints, the former could give too small a block for the return value when, e.g., mode = 2 or 4 and ndigits = 24 (16 for 16-bit ints). Mon Jun 21 12:56:42 EDT 1993 dtoa.c: tweak to work with 32-bit ints and 64-bit longs when compiled with -DLong=int . Wed Jan 26 11:09:16 EST 1994 dtoa.c: fix bug in strtod's handling of numbers with very negative exponents (e.g. 1.8826e-512), which should underflow to 0; fix storage leak in strtod with underflows and overflows near the underflow and overflow thresholds. Mon Feb 28 11:37:30 EST 1994 dtoa.c: 85a86,89 > * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) > * if memory is available and otherwise does something you deem > * appropriate. If MALLOC is undefined, malloc will be invoked > * directly -- and assumed always to succeed. 87a92,95 > #ifndef MALLOC > #define MALLOC malloc > #endif > 352c360 < rv = (Bigint *)malloc(sizeof(Bigint) + (x-1)*sizeof(Long)); --- > rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long)); Thu Mar 3 16:56:39 EST 1994 dtoa.c: if MALLOC is #defined, declare it. Wed Jan 4 15:45:34 EST 1995 dtoa.c: add CONST qualification to tens, bigtens, tinytens (for use on embedded systems with little spare RAM). Fri Mar 1 08:55:39 EST 1996 g_fmt.c: honor the sign of 0 and return the first argument (buf). Sat Jul 6 07:59:28 EDT 1996 dtoa.c: cosmetic changes: "ULong" rather than "unsigned Long"; update comments to reflect AT&T breakup. Mon Aug 5 23:31:24 EDT 1996 dtoa.c: add comment about invoking _control87(PC_53, MCW_PC) (or the equivalent) on 80x87 machines before calling strtod or dtoa. Tue Dec 17 15:01:56 EST 1996 dtoa.c: new #define possibilities: #define INFNAN_CHECK to have strtod check (case insensitively) for "Infinity" and "NaN" on machines with IEEE arithmetic; #define MULTIPLE_THREADS if the system offers preemptively scheduled multiple threads, in which case you must supply routines ACQUIRE_DTOA_LOCK(n) and FREE_DTOA_LOCK(n) (n = 0 or 1). New void freedtoa(char*) for freeing values returned by dtoa; use of freedtoa() is required if MULTIPLE_THREADS is #defined, and is merely recommended otherwise. g_fmt.c: adjusted to invoke freedtoa(). Wed Feb 12 00:40:01 EST 1997 dtoa.c: strtod: on IEEE systems, scale to avoid intermediate underflows when the result does not underflow; compiling with -DNO_IEEE_Scale restores the old logic. Fix a bug, revealed by input string 2.2250738585072012e-308, in treating input just less than the smallest normalized number. (The bug introduced an extra ULP of error in this special case.) Tue May 12 11:13:04 EDT 1998 dtoa.c: strtod: fix a glitch introduced with the scaling of 19970212 that caused one-bit rounding errors in certain denormal numbers, such as 8.44291197326099e-309, which was read as 8.442911973260987e-309. Remove #ifdef Unsigned_Shifts logic in favor of unsigned arithmetic. Unless compiled with -DNO_LONG_LONG, use 64-bit arithmetic where possible. Fri May 15 07:49:07 EDT 1998 dtoa.c: strtod: fix another glitch with scaling to avoid underflow with IEEE arithmetic, again revealed by the input string 2.2250738585072012e-308, which was rounded to the largest denormal rather than the smallest normal double precision number. Wed Aug 5 23:27:26 EDT 1998 gdtoa.tar.gz: tweaks in response to comments from Shawn C. Sheridan (with no effect on the resulting .o files except when strtod.c is compiled with -DNO_ERRNO); bigtens --> bigtens_D2A (a symbol meant to be private to gdtoa.a). Sat Sep 12 17:05:15 EDT 1998 gdtoa.tar.gz: more changes in response to comments from Shawn C. Sheridan (including repair of a glitch in g_ffmt.c). For consistency and possible convenience, there are some new functions and some name changes to existing ones: Old New --- g_xLfmt strtoQ strtopQ --- strtopd strtodd strtopdd --- strtopf strtox strtopx --- strtopxL --- strtorxL --- strtoIxL Functions strtopd and strtopf are variations of strtod and strtof, respectively, which write their results to their final (pointer) arguments. Functions strtorf and strtord are now analogous to the other strtor* functions in that they now have a final pointer argument to which they write their results, and they return the int value they get from strtodg. The xL family (g_xLfmt, strto[Irp]xL) is a variation of the old x family (for 80-bit IEEE double-extended precision) that assumes the storage layout of the Motorola 68881's double-extended format: 80 interesting bits stored in 3 unsigned 32-bit ints (with a "hole", 16 zero bits, in the word that holds the sign and exponent). The x family now deals with 80-bit (5 unsigned 16-bit ints) rather than 96-bit arrays (3 unsigned 32-bit ints) that hold its 80-bit double-extended values. (This relaxes the alignment requirements of the x family and results in strto[Ipr]x writing 80 rather than 96 bits to their final arguments.) Each g_*fmt routine now returns a pointer to the null character that terminates the strings it writes, rather than a pointer to the beginning of that string (the first argument). These routines still return 0 (NULL) if the first argument is too short. The second argument to g_dfmt is now pointer (to a double) rather than a double value. Thu Oct 29 21:54:00 EST 1998 dtoa.c: Fix bug in strtod under -DSudden_Underflow and (the default) -DAvoid_Underflow: some numbers that should have suffered sudden underflow were scaled inappropriately (giving nonzero return values). Example: "1e-320" gave -3.6304123742133376e+280 rather than 0. Mon Nov 2 15:41:16 EST 1998 dtoa.c: tweak to remove LL suffixes from numeric constants (for compilers that offer a 64-bit long long type but do not recognize the LL constants prescribed by C9x, the proposed update to the ANSI/ISO C standard). Thanks to Earl Chew for pointing out the existence of such compilers. gdtoa.tar.gz: renamed gdtoa.tgz and updated to incorporate the above changes (of 29 Oct. and 2 Nov. 1998) to dtoa.c. Thu Mar 25 17:56:44 EST 1999 dtoa.c, gdtoa.tgz: fix a bug in strtod's reading of 4.9e-324: it returned 0 rather than the smallest denormal. Mon Apr 12 10:39:25 EDT 1999 gdtoa.tgz: test/ftest.c: change %.7g to %.8g throughout. Fri Aug 20 19:17:52 EDT 1999 gdtoa.tgz: gdtoa.c: fix two bugs reported by David Chase (thanks!): 1. An adjustment for denormalized numbers around 503 was off by one. 2. A check for "The special case" around line 551 omitted the condition that we not be at the bottom of the exponent range. Mon Sep 13 10:53:34 EDT 1999 dtoa.c: computationally invisible tweak for the benefit of people who actually read the code: 2671c2671 < && word0(d) & Exp_mask --- > && word0(d) & (Exp_mask & Exp_mask << 1) I.e., in dtoa(), the "special case" does not arise for the smallest normalized IEEE double. Thanks to Waldemar Horwat for pointing this out and suggesting the modified test above. Also, some tweaks for compilation with -DKR_headers. gdtoa.tgz: gdtoa.c: analogous change: 552c552 < if (bbits == 1 && be0 > fpi->emin) { --- > if (bbits == 1 && be0 > fpi->emin + 1) { This has no effect on the g*fmt.c routines, but might affect the computation of the shortest decimal string that rounds to the smallest normalized floating-point number of other precisions. gdota.tgz: test/d.out test/dI.out test/dd.out: updated to reflect previous changes (of 19990820); test/*.c: most test programs modified to permit #hex input. See the comments. Fri Sep 17 01:39:25 EDT 1999 Try again to update dtoa.c: somehow dtoa.c got put back to a version from 3 years ago after this "changes" file was updated on 13 Sept. 1999. One more tweak to omit a warning on some systems: 2671c2671 < && word0(d) & (Exp_mask & Exp_mask << 1) --- > && word0(d) & (Exp_mask & ~Exp_msk1) Plus changes to avoid trouble with aggressively optimizing compilers (e.g., gcc 2.95.1 under -O2). On some systems, these changes do not affect the resulting machine code; on others, the old way of viewing a double as a pair of ULongs is available with -DYES_ALIAS. Tue Sep 21 09:21:25 EDT 1999 gdtoa.tgz: changes analogous to those of 17 Sept. 1999 to dtoa.c to avoid trouble with aggressively optimizing compilers. Wed Dec 15 13:14:38 EST 1999 dtoa.c: tweak to bypass a bug with HUGE_VAL on HP systems. Mon Jan 17 18:32:52 EST 2000 dtoa.c and gdtoa.tgz: strtod: set errno = ERANGE on all inputs that underflow to zero (not just those sufficiently less than the smallest positive denormalized number). gdtoa.tgz: README: point out that compiling with -DNO_ERRNO inhibits errno assignments (by strtod and the core converter, strtodg). Tue Jan 18 16:35:31 EST 2000 dtoa.c and gdtoa.tgz: strtod: modify the test inserted yesterday so it may work correctly with buggy 80x87 compilers. (The change matters, e.g., to Microsoft Visual C++ 4.2 and 6.0.) Thu Nov 2 21:00:45 EST 2000 dtoa.c and gdtoa.tgz: 1. Fix bug in test for exact half-way cases of denormalized numbers (without -DNO_IEEE_Scale). 2. Compilation with -DNO_ERRNO prevents strtod from assigning errno = ERANGE when the result overflows or underflows to 0. 3. With IEEE arithmetic and no -DNO_IEEE_Scale, adjust scaling so ulp(d) never returns a denormalized number. This and other tweaks permit strtod and dtoa to work correctly on machines that flush underflows to zero but otherwise use IEEE arithmetic without Sudden_Underflow being #defined (and with strtod simply returning 0 instead of denormalized numbers). 4. Compilations with -DUSE_LOCALE causes strtod to use the current locale's decimal_point value. 5. Under compilations with -DINFNAN_CHECK, strtod and strtodg (case insensitively) treat "inf" the same as "infinity" and, unless compiled with -DNo_Hex_NaN, accept "nan(x)", where x is a string of hexadecimal digits and spaces, as a NaN whose value is constructed from x (as explained in comments near the top of dtoa.c and in gdtoaimp.h). 6. The default PRIVATE_MEM is increased slightly (to 2304), and comments near the top of dtoa.c provide more discussion of PRIVATE_MEM. 7. Meanings of dtoa modes 4,5,8,9 changed. See comments in dtoa.c and gdtoa.c; modes 4 and 5 may now provide shorter strings that round (in round-nearest mode) to the given double value. (Paxson's testbase program is unhappy with this new rounding, as it can introduce an error of more than one base-10 ulp when 17 or more decimal digits are requested.) 8. With IEEE arithmetic, compilation with -DHonor_FLT_ROUNDS causes strtod and dtoa to round according to FLT_ROUNDS: 0 ==> towards 0, 1 ==> nearest, 2 ==> towards +Infinity, 3 ==> towards -Infinity. 9. With IEEE arithmetic, compilation with -DSET_INEXACT causes extra computation (and sometimes slower conversions in dtoa and strtod, particularly for dtoa in cases where otherwise some simple floating- point computations would suffice) to set the IEEE inexact flag correctly. As comments in dtoa.c explain in more detail, this requires compilation in an environment (such as #include "dtoa.c" in suitable source) that provides int get_inexact(void); void clear_inexact(void); 10. On input "-x", return 0 rather than -0. gdtoa.tgz: gethex.c: adjust logic for reading hex constants to accord with current wording of the C99 standard. Previously, I thought hex constants read by strtod and friends had to have either a decimal point or an exponent field; p. 307 of the C99 standard states that both are optional. Because of the complexity of this reading, it is available only in the variant of strtod that appears in gdtoa.tgz. strtodg (gdtoa.tgz): New return value STRTOG_NaNbits (with STRTOG_NoNumber renumbered). Allow STRTOG_Neg bit in strtodg returns for STRTOG_NaN and STRTOG_NaNbits. gdtoa.tgz: Fix uninitialized variable bug in g_Qfmt.c's handling of NaNs. Mon Nov 13 14:00:05 EST 2000 gdtoa.tgz: strtodg: fix a storage leak and an apparently rare infinite loop with a boundary case of directed rounding. Example input to gdtoa/test/Qtest where the loop bug bit: r 3 35184372088831.999999999999999999999999999999999999 This was revealed by testbase for quad precision Solaris arithmetic; it did not show up in several other testbase configurations. Wed Feb 7 12:56:11 EST 2001 dtoa.c: fix bug (possible infinite loop, e.g., with 2.47032822920623272e-324) introduced 20001113 in handling the special case of a power of 2 to be rounded down one ulp. Add test (required by changes of 20001113) for the extra special case of 2^-1075 (half the smallest denormal). gdtoa.tgz: corresponding adjustments to strtod.c and strtodg.c. Tue Mar 13 00:46:09 EST 2001 gdtoa.tgz: gdtoa/strtodg.c: fix bug in handling values exactly half an ulp less than the smallest normal floating-point number; gdtoa/*test.c: fix glitch in handling "n ..." lines (intended to change "ndig"). Wed Mar 6 10:13:52 EST 2002 gdtoa.tgz: add gdtoa/test/strtodt.c and gdtoa/test/testnos3 to test strtod on hard cases posted by Fred Tydeman to comp.arch.arithmetic on 26 Feb. 1996. Add comment to gdtoa/README about strtod requiring true IEEE arithmetic (with 53-bit rounding precision on 80x87 chips). In gdtoa/test, automate selection of expected output files [xQ]*.out. Wed Mar 5 10:35:41 EST 2003 gdtoa.tgz: fix a bug in strtod's handling of 0-valued 0x... "decimal" strings. A fault was possible. Thanks to David Shultz for reporting this bug. Tue Mar 18 09:38:28 EST 2003 gdtoa.tgz: fix a glitch in strtodg.c with -DUSE_LOCALE; add #ifdef USE_LOCALE lines to g__fmt.c (to affect binary --> decimal conversions via the g*fmt routines), and add comments about -DUSE_LOCALE to README. In short, compiling strtod.c, strtodg.c, and g__fmt.c with -DUSE_LOCALE causes them to determine the decimal-point character from the current locale. (Otherwise it is '.'.) Fri Mar 21 16:36:27 EST 2003 gdtoa.tgz: gethex.c: add #ifdef USE_LOCAL logic; strtod.c: fix a glitch in handling 0x... input (the return from gethex was ignored). Wed Mar 26 15:35:10 EST 2003 gdtoa.tgz: gethex.c: pedantic (and normally invisible) change: use unsigned char for decimalpoint variable (under -DUSE_LOCALE). Sat Jan 17 23:58:52 MST 2004 gdtoa.tgz: gethex.c: supply missing parens in test for whether a denormal result should be zero, correct logic for rounding up when the result is denormal, and when returning zero or Infinity, set *bp = 0; strtod.c: switch on gethex(...) & STRTOG_Retmask rather than just on gethex(), and only copybits(..., bb) when bb is nonzero. This mattered for underflows and overflows in 0x notation. Thu Mar 25 22:34:56 MST 2004 dtoa.c and gdtoa.c/misc.c: change "(!x & 1)" to "(!x)" to avoid confusion by human readers -- the object code is unaffected (with reasonable compilers). Mon Apr 12 00:44:22 MDT 2004 dtoa.c and gdtoa.tar.gz: update contact info. for dmg and correct page numbers in comment on Steele & White (1990). gdtoa.tgz: add strtodnrp.c for a variant of strtod that is slower but does not require 53-bit rounding precision on Intel IA32 systems. Tue Apr 13 00:28:14 MDT 2004 gdtoa.tgz: strtod.c: fix glitch when both INFNAN_CHECK and No_Hex_NaN are #defined. Thanks to David Mendenhall for pointing this bug out. Wed Jan 5 22:39:17 MST 2005 gdtoa.tgz: gethex.c: fix the bug reported by Stefan Farfeleder of ignoring a binary-exponent-part if the converted number is zero. strto[pr]x.c: fix bug reported by Stefan Farfeleder in setting the exponent of denormals (which should be 0, not 1). g_xfmt.c: fix a corresponding bug with denormals. strtodg.c: fix a bug under IBM (base 16) arithemtic reported by Greg Alexander: a correction to the binary exponent for changes to the exponent of a native double value for avoiding overflow had to be multiplied by 4 ("e2 <<= 2;"). Various files: minor tweaks for portability. Sat Jan 15 15:36:03 MST 2005 gdtoa.tgz: gethex.c: fix a glitch introduced last week (and reported by Stefan Farfelder) with 0x forms with no nonzero digits before the "." character, e.g., 0x.1 (which was rendered as 0 rather than .0625). gdtoa.tgz: many files: add automatic computation of gd_qnan.h for giving the system-dependent format of a quiet NaN (the one generated for Infinity - Infinity). Tweak test/makefile so differences in the spelling of Infinity ("INF" or "Inf" on some systems) do not matter. Fix bug in strtod.c and strtodg.c under which, e.g., -.nan was read as NaN rather than unacceptable input (causing return 0). Adjust comments in README about nan(...). Fix glitch in test/dt.c. Sun Jan 16 18:22:13 MST 2005 gdtoa.tgz: strtodg.c: fix long-standing bug in handling input that rounds up to 2^nbits, e.g., strtof("16777215.5"). Thanks to Edward Moy for reporting this problem. gdtoa.tgz: Fix some bugs with -DJust_16.