1cc36ccd1SDavid SchultzThis directory contains source for a library of binary -> decimal 2cc36ccd1SDavid Schultzand decimal -> binary conversion routines, for single-, double-, 3cc36ccd1SDavid Schultzand extended-precision IEEE binary floating-point arithmetic, and 4cc36ccd1SDavid Schultzother IEEE-like binary floating-point, including "double double", 5cc36ccd1SDavid Schultzas in 6cc36ccd1SDavid Schultz 7cc36ccd1SDavid Schultz T. J. Dekker, "A Floating-Point Technique for Extending the 8cc36ccd1SDavid Schultz Available Precision", Numer. Math. 18 (1971), pp. 224-242 9cc36ccd1SDavid Schultz 10cc36ccd1SDavid Schultzand 11cc36ccd1SDavid Schultz 12cc36ccd1SDavid Schultz "Inside Macintosh: PowerPC Numerics", Addison-Wesley, 1994 13cc36ccd1SDavid Schultz 14cc36ccd1SDavid SchultzThe conversion routines use double-precision floating-point arithmetic 15cc36ccd1SDavid Schultzand, where necessary, high precision integer arithmetic. The routines 16cc36ccd1SDavid Schultzare generalizations of the strtod and dtoa routines described in 17cc36ccd1SDavid Schultz 18cc36ccd1SDavid Schultz David M. Gay, "Correctly Rounded Binary-Decimal and 19cc36ccd1SDavid Schultz Decimal-Binary Conversions", Numerical Analysis Manuscript 20cc36ccd1SDavid Schultz No. 90-10, Bell Labs, Murray Hill, 1990; 21cc36ccd1SDavid Schultz http://cm.bell-labs.com/cm/cs/what/ampl/REFS/rounding.ps.gz 22cc36ccd1SDavid Schultz 23cc36ccd1SDavid Schultz(based in part on papers by Clinger and Steele & White: see the 24cc36ccd1SDavid Schultzreferences in the above paper). 25cc36ccd1SDavid Schultz 26cc36ccd1SDavid SchultzThe present conversion routines should be able to use any of IEEE binary, 27cc36ccd1SDavid SchultzVAX, or IBM-mainframe double-precision arithmetic internally, but I (dmg) 28cc36ccd1SDavid Schultzhave so far only had a chance to test them with IEEE double precision 29cc36ccd1SDavid Schultzarithmetic. 30cc36ccd1SDavid Schultz 31cc36ccd1SDavid SchultzThe core conversion routines are strtodg for decimal -> binary conversions 32cc36ccd1SDavid Schultzand gdtoa for binary -> decimal conversions. These routines operate 33cc36ccd1SDavid Schultzon arrays of unsigned 32-bit integers of type ULong, a signed 32-bit 34cc36ccd1SDavid Schultzexponent of type Long, and arithmetic characteristics described in 35cc36ccd1SDavid Schultzstruct FPI; FPI, Long, and ULong are defined in gdtoa.h. File arith.h 36cc36ccd1SDavid Schultzis supposed to provide #defines that cause gdtoa.h to define its 37cc36ccd1SDavid Schultztypes correctly. File arithchk.c is source for a program that 38cc36ccd1SDavid Schultzgenerates a suitable arith.h on all systems where I've been able to 39cc36ccd1SDavid Schultztest it. 40cc36ccd1SDavid Schultz 41cc36ccd1SDavid SchultzThe core conversion routines are meant to be called by helper routines 42cc36ccd1SDavid Schultzthat know details of the particular binary arithmetic of interest and 43cc36ccd1SDavid Schultzconvert. The present directory provides helper routines for 5 variants 44cc36ccd1SDavid Schultzof IEEE binary floating-point arithmetic, each indicated by one or 45cc36ccd1SDavid Schultztwo letters: 46cc36ccd1SDavid Schultz 47cc36ccd1SDavid Schultz f IEEE single precision 48cc36ccd1SDavid Schultz d IEEE double precision 49cc36ccd1SDavid Schultz x IEEE extended precision, as on Intel 80x87 50cc36ccd1SDavid Schultz and software emulations of Motorola 68xxx chips 51cc36ccd1SDavid Schultz that do not pad the way the 68xxx does, but 52cc36ccd1SDavid Schultz only store 80 bits 53cc36ccd1SDavid Schultz xL IEEE extended precision, as on Motorola 68xxx chips 54cc36ccd1SDavid Schultz Q quad precision, as on Sun Sparc chips 55cc36ccd1SDavid Schultz dd double double, pairs of IEEE double numbers 56cc36ccd1SDavid Schultz whose sum is the desired value 57cc36ccd1SDavid Schultz 58cc36ccd1SDavid SchultzFor decimal -> binary conversions, there are three families of 59cc36ccd1SDavid Schultzhelper routines: one for round-nearest: 60cc36ccd1SDavid Schultz 61cc36ccd1SDavid Schultz strtof 62cc36ccd1SDavid Schultz strtod 63cc36ccd1SDavid Schultz strtodd 64cc36ccd1SDavid Schultz strtopd 65cc36ccd1SDavid Schultz strtopf 66cc36ccd1SDavid Schultz strtopx 67cc36ccd1SDavid Schultz strtopxL 68cc36ccd1SDavid Schultz strtopQ 69cc36ccd1SDavid Schultz 70cc36ccd1SDavid Schultzone with rounding direction specified: 71cc36ccd1SDavid Schultz 72cc36ccd1SDavid Schultz strtorf 73cc36ccd1SDavid Schultz strtord 74cc36ccd1SDavid Schultz strtordd 75cc36ccd1SDavid Schultz strtorx 76cc36ccd1SDavid Schultz strtorxL 77cc36ccd1SDavid Schultz strtorQ 78cc36ccd1SDavid Schultz 79cc36ccd1SDavid Schultzand one for computing an interval (at most one bit wide) that contains 80cc36ccd1SDavid Schultzthe decimal number: 81cc36ccd1SDavid Schultz 82cc36ccd1SDavid Schultz strtoIf 83cc36ccd1SDavid Schultz strtoId 84cc36ccd1SDavid Schultz strtoIdd 85cc36ccd1SDavid Schultz strtoIx 86cc36ccd1SDavid Schultz strtoIxL 87cc36ccd1SDavid Schultz strtoIQ 88cc36ccd1SDavid Schultz 89cc36ccd1SDavid SchultzThe latter call strtoIg, which makes one call on strtodg and adjusts 90cc36ccd1SDavid Schultzthe result to provide the desired interval. On systems where native 91cc36ccd1SDavid Schultzarithmetic can easily make one-ulp adjustments on values in the 92cc36ccd1SDavid Schultzdesired floating-point format, it might be more efficient to use the 93cc36ccd1SDavid Schultznative arithmetic. Routine strtodI is a variant of strtoId that 94cc36ccd1SDavid Schultzillustrates one way to do this for IEEE binary double-precision 95cc36ccd1SDavid Schultzarithmetic -- but whether this is more efficient remains to be seen. 96cc36ccd1SDavid Schultz 97cc36ccd1SDavid SchultzFunctions strtod and strtof have "natural" return types, float and 98cc36ccd1SDavid Schultzdouble -- strtod is specified by the C standard, and strtof appears 99cc36ccd1SDavid Schultzin the stdlib.h of some systems, such as (at least some) Linux systems. 100cc36ccd1SDavid SchultzThe other functions write their results to their final argument(s): 101cc36ccd1SDavid Schultzto the final two argument for the strtoI... (interval) functions, 102cc36ccd1SDavid Schultzand to the final argument for the others (strtop... and strtor...). 103cc36ccd1SDavid SchultzWhere possible, these arguments have "natural" return types (double* 104cc36ccd1SDavid Schultzor float*), to permit at least some type checking. In reality, they 105cc36ccd1SDavid Schultzare viewed as arrays of ULong (or, for the "x" functions, UShort) 106cc36ccd1SDavid Schultzvalues. On systems where long double is the appropriate type, one can 107cc36ccd1SDavid Schultzpass long double* final argument(s) to these routines. The int value 108cc36ccd1SDavid Schultzthat these routines return is the return value from the call they make 109cc36ccd1SDavid Schultzon strtodg; see the enum of possible return values in gdtoa.h. 110cc36ccd1SDavid Schultz 111cc36ccd1SDavid SchultzSource files g_ddfmt.c, misc.c, smisc.c, strtod.c, strtodg.c, and ulp.c 112cc36ccd1SDavid Schultzshould use true IEEE double arithmetic (not, e.g., double extended), 113cc36ccd1SDavid Schultzat least for storing (and viewing the bits of) the variables declared 114cc36ccd1SDavid Schultz"double" within them. 115cc36ccd1SDavid Schultz 116cc36ccd1SDavid SchultzOne detail indicated in struct FPI is whether the target binary 117cc36ccd1SDavid Schultzarithmetic departs from the IEEE standard by flushing denormalized 118cc36ccd1SDavid Schultznumbers to 0. On systems that do this, the helper routines for 119cc36ccd1SDavid Schultzconversion to double-double format (when compiled with 120cc36ccd1SDavid SchultzSudden_Underflow #defined) penalize the bottom of the exponent 121cc36ccd1SDavid Schultzrange so that they return a nonzero result only when the least 122cc36ccd1SDavid Schultzsignificant bit of the less significant member of the pair of 123cc36ccd1SDavid Schultzdouble values returned can be expressed as a normalized double 124cc36ccd1SDavid Schultzvalue. An alternative would be to drop to 53-bit precision near 125cc36ccd1SDavid Schultzthe bottom of the exponent range. To get correct rounding, this 126cc36ccd1SDavid Schultzwould (in general) require two calls on strtodg (one specifying 127cc36ccd1SDavid Schultz126-bit arithmetic, then, if necessary, one specifying 53-bit 128cc36ccd1SDavid Schultzarithmetic). 129cc36ccd1SDavid Schultz 130cc36ccd1SDavid SchultzBy default, the core routine strtodg and strtod set errno to ERANGE 131cc36ccd1SDavid Schultzif the result overflows to +Infinity or underflows to 0. Compile 132cc36ccd1SDavid Schultzthese routines with NO_ERRNO #defined to inhibit errno assignments. 133cc36ccd1SDavid Schultz 134cc36ccd1SDavid SchultzRoutine strtod is based on netlib's "dtoa.c from fp", and 135cc36ccd1SDavid Schultz(f = strtod(s,se)) is more efficient for some conversions than, say, 136cc36ccd1SDavid Schultzstrtord(s,se,1,&f). Parts of strtod require true IEEE double 137cc36ccd1SDavid Schultzarithmetic with the default rounding mode (round-to-nearest) and, on 138cc36ccd1SDavid Schultzsystems with IEEE extended-precision registers, double-precision 139cc36ccd1SDavid Schultz(53-bit) rounding precision. If the machine uses (the equivalent of) 140cc36ccd1SDavid SchultzIntel 80x87 arithmetic, the call 141cc36ccd1SDavid Schultz _control87(PC_53, MCW_PC); 142cc36ccd1SDavid Schultzdoes this with many compilers. Whether this or another call is 143cc36ccd1SDavid Schultzappropriate depends on the compiler; for this to work, it may be 144cc36ccd1SDavid Schultznecessary to #include "float.h" or another system-dependent header 145cc36ccd1SDavid Schultzfile. 146cc36ccd1SDavid Schultz 147c88250a5SDavid SchultzSource file strtodnrp.c gives a strtod that does not require 53-bit 148c88250a5SDavid Schultzrounding precision on systems (such as Intel IA32 systems) that may 149c88250a5SDavid Schultzsuffer double rounding due to use of extended-precision registers. 150c88250a5SDavid SchultzFor some conversions this variant of strtod is less efficient than the 151c88250a5SDavid Schultzone in strtod.c when the latter is run with 53-bit rounding precision. 152c88250a5SDavid Schultz 153c88250a5SDavid SchultzThe values that the strto* routines return for NaNs are determined by 154c88250a5SDavid Schultzgd_qnan.h, which the makefile generates by running the program whose 155c88250a5SDavid Schultzsource is qnan.c. Note that the rules for distinguishing signaling 156c88250a5SDavid Schultzfrom quiet NaNs are system-dependent. For cross-compilation, you need 157c88250a5SDavid Schultzto determine arith.h and gd_qnan.h suitably, e.g., using the 158c88250a5SDavid Schultzarithmetic of the target machine. 159cc36ccd1SDavid Schultz 160cc36ccd1SDavid SchultzC99's hexadecimal floating-point constants are recognized by the 161cc36ccd1SDavid Schultzstrto* routines (but this feature has not yet been heavily tested). 162cc36ccd1SDavid SchultzCompiling with NO_HEX_FP #defined disables this feature. 163cc36ccd1SDavid Schultz 164c88250a5SDavid SchultzWhen compiled with -DINFNAN_CHECK, the strto* routines recognize C99's 165c88250a5SDavid SchultzNaN and Infinity syntax. Moreover, unless No_Hex_NaN is #defined, the 166c88250a5SDavid Schultzstrto* routines also recognize C99's NaN(...) syntax: they accept 167c88250a5SDavid Schultz(case insensitively) strings of the form NaN(x), where x is a string 168c88250a5SDavid Schultzof hexadecimal digits and spaces; if there is only one string of 169c88250a5SDavid Schultzhexadecimal digits, it is taken for the fraction bits of the resulting 170c88250a5SDavid SchultzNaN; if there are two or more strings of hexadecimal digits, each 171c88250a5SDavid Schultzstring is assigned to the next available sequence of 32-bit words of 172c88250a5SDavid Schultzfractions bits (starting with the most significant), right-aligned in 173c88250a5SDavid Schultzeach sequence. 174cc36ccd1SDavid Schultz 175cc36ccd1SDavid SchultzFor binary -> decimal conversions, I've provided just one family 176cc36ccd1SDavid Schultzof helper routines: 177cc36ccd1SDavid Schultz 178cc36ccd1SDavid Schultz g_ffmt 179cc36ccd1SDavid Schultz g_dfmt 180cc36ccd1SDavid Schultz g_ddfmt 181cc36ccd1SDavid Schultz g_xfmt 182cc36ccd1SDavid Schultz g_xLfmt 183cc36ccd1SDavid Schultz g_Qfmt 184cc36ccd1SDavid Schultz 185cc36ccd1SDavid Schultzwhich do a "%g" style conversion either to a specified number of decimal 186cc36ccd1SDavid Schultzplaces (if their ndig argument is positive), or to the shortest 187cc36ccd1SDavid Schultzdecimal string that rounds to the given binary floating-point value 188cc36ccd1SDavid Schultz(if ndig <= 0). They write into a buffer supplied as an argument 189cc36ccd1SDavid Schultzand return either a pointer to the end of the string (a null character) 190cc36ccd1SDavid Schultzin the buffer, if the buffer was long enough, or 0. Other forms of 191cc36ccd1SDavid Schultzconversion are easily done with the help of gdtoa(), such as %e or %f 192cc36ccd1SDavid Schultzstyle and conversions with direction of rounding specified (so that, if 193cc36ccd1SDavid Schultzdesired, the decimal value is either >= or <= the binary value). 194cc36ccd1SDavid Schultz 195cc36ccd1SDavid SchultzFor an example of more general conversions based on dtoa(), see 196cc36ccd1SDavid Schultznetlib's "printf.c from ampl/solvers". 197cc36ccd1SDavid Schultz 198cc36ccd1SDavid SchultzFor double-double -> decimal, g_ddfmt() assumes IEEE-like arithmetic 199cc36ccd1SDavid Schultzof precision max(126, #bits(input)) bits, where #bits(input) is the 200cc36ccd1SDavid Schultznumber of mantissa bits needed to represent the sum of the two double 201cc36ccd1SDavid Schultzvalues in the input. 202cc36ccd1SDavid Schultz 203cc36ccd1SDavid SchultzThe makefile creates a library, gdtoa.a. To use the helper 204cc36ccd1SDavid Schultzroutines, a program only needs to include gdtoa.h. All the 205cc36ccd1SDavid Schultzsource files for gdtoa.a include a more extensive gdtoaimp.h; 206cc36ccd1SDavid Schultzamong other things, gdtoaimp.h has #defines that make "internal" 207cc36ccd1SDavid Schultznames end in _D2A. To make a "system" library, one could modify 208cc36ccd1SDavid Schultzthese #defines to make the names start with __. 209cc36ccd1SDavid Schultz 210cc36ccd1SDavid SchultzVarious comments about possible #defines appear in gdtoaimp.h, 211cc36ccd1SDavid Schultzbut for most purposes, arith.h should set suitable #defines. 212cc36ccd1SDavid Schultz 213cc36ccd1SDavid SchultzSystems with preemptive scheduling of multiple threads require some 214cc36ccd1SDavid Schultzmanual intervention. On such systems, it's necessary to compile 215cc36ccd1SDavid Schultzdmisc.c, dtoa.c gdota.c, and misc.c with MULTIPLE_THREADS #defined, 216cc36ccd1SDavid Schultzand to provide (or suitably #define) two locks, acquired by 217cc36ccd1SDavid SchultzACQUIRE_DTOA_LOCK(n) and freed by FREE_DTOA_LOCK(n) for n = 0 or 1. 218cc36ccd1SDavid Schultz(The second lock, accessed in pow5mult, ensures lazy evaluation of 219cc36ccd1SDavid Schultzonly one copy of high powers of 5; omitting this lock would introduce 220cc36ccd1SDavid Schultza small probability of wasting memory, but would otherwise be harmless.) 221cc36ccd1SDavid SchultzRoutines that call dtoa or gdtoa directly must also invoke freedtoa(s) 222cc36ccd1SDavid Schultzto free the value s returned by dtoa or gdtoa. It's OK to do so whether 223cc36ccd1SDavid Schultzor not MULTIPLE_THREADS is #defined, and the helper g_*fmt routines 224cc36ccd1SDavid Schultzlisted above all do this indirectly (in gfmt_D2A(), which they all call). 225cc36ccd1SDavid Schultz 226cc36ccd1SDavid SchultzBy default, there is a private pool of memory of length 2000 bytes 227cc36ccd1SDavid Schultzfor intermediate quantities, and MALLOC (see gdtoaimp.h) is called only 228cc36ccd1SDavid Schultzif the private pool does not suffice. 2000 is large enough that MALLOC 229cc36ccd1SDavid Schultzis called only under very unusual circumstances (decimal -> binary 230cc36ccd1SDavid Schultzconversion of very long strings) for conversions to and from double 231c88250a5SDavid Schultzprecision. For systems with preemptively scheduled multiple threads 232cc36ccd1SDavid Schultzor for conversions to extended or quad, it may be appropriate to 233cc36ccd1SDavid Schultz#define PRIVATE_MEM nnnn, where nnnn is a suitable value > 2000. 234cc36ccd1SDavid SchultzFor extended and quad precisions, -DPRIVATE_MEM=20000 is probably 235cc36ccd1SDavid Schultzplenty even for many digits at the ends of the exponent range. 236cc36ccd1SDavid SchultzUse of the private pool avoids some overhead. 237cc36ccd1SDavid Schultz 238cc36ccd1SDavid SchultzDirectory test provides some test routines. See its README. 239cc36ccd1SDavid SchultzI've also tested this stuff (except double double conversions) 240cc36ccd1SDavid Schultzwith Vern Paxson's testbase program: see 241cc36ccd1SDavid Schultz 242cc36ccd1SDavid Schultz V. Paxson and W. Kahan, "A Program for Testing IEEE Binary-Decimal 243cc36ccd1SDavid Schultz Conversion", manuscript, May 1991, 244cc36ccd1SDavid Schultz ftp://ftp.ee.lbl.gov/testbase-report.ps.Z . 245cc36ccd1SDavid Schultz 246cc36ccd1SDavid Schultz(The same ftp directory has source for testbase.) 247cc36ccd1SDavid Schultz 248cc36ccd1SDavid SchultzSome system-dependent additions to CFLAGS in the makefile: 249cc36ccd1SDavid Schultz 250cc36ccd1SDavid Schultz HU-UX: -Aa -Ae 251cc36ccd1SDavid Schultz OSF (DEC Unix): -ieee_with_no_inexact 252cc36ccd1SDavid Schultz SunOS 4.1x: -DKR_headers -DBad_float_h 253cc36ccd1SDavid Schultz 254cc36ccd1SDavid SchultzIf you want to put this stuff into a shared library and your 255cc36ccd1SDavid Schultzoperating system requires export lists for shared libraries, 256cc36ccd1SDavid Schultzthe following would be an appropriate export list: 257cc36ccd1SDavid Schultz 258cc36ccd1SDavid Schultz dtoa 259cc36ccd1SDavid Schultz freedtoa 260cc36ccd1SDavid Schultz g_Qfmt 261cc36ccd1SDavid Schultz g_ddfmt 262cc36ccd1SDavid Schultz g_dfmt 263cc36ccd1SDavid Schultz g_ffmt 264cc36ccd1SDavid Schultz g_xLfmt 265cc36ccd1SDavid Schultz g_xfmt 266cc36ccd1SDavid Schultz gdtoa 267cc36ccd1SDavid Schultz strtoIQ 268cc36ccd1SDavid Schultz strtoId 269cc36ccd1SDavid Schultz strtoIdd 270cc36ccd1SDavid Schultz strtoIf 271cc36ccd1SDavid Schultz strtoIx 272cc36ccd1SDavid Schultz strtoIxL 273cc36ccd1SDavid Schultz strtod 274cc36ccd1SDavid Schultz strtodI 275cc36ccd1SDavid Schultz strtodg 276cc36ccd1SDavid Schultz strtof 277cc36ccd1SDavid Schultz strtopQ 278cc36ccd1SDavid Schultz strtopd 279cc36ccd1SDavid Schultz strtopdd 280cc36ccd1SDavid Schultz strtopf 281cc36ccd1SDavid Schultz strtopx 282cc36ccd1SDavid Schultz strtopxL 283cc36ccd1SDavid Schultz strtorQ 284cc36ccd1SDavid Schultz strtord 285cc36ccd1SDavid Schultz strtordd 286cc36ccd1SDavid Schultz strtorf 287cc36ccd1SDavid Schultz strtorx 288cc36ccd1SDavid Schultz strtorxL 289cc36ccd1SDavid Schultz 290cc36ccd1SDavid SchultzWhen time permits, I (dmg) hope to write in more detail about the 291cc36ccd1SDavid Schultzpresent conversion routines; for now, this README file must suffice. 292cc36ccd1SDavid SchultzMeanwhile, if you wish to write helper functions for other kinds of 293cc36ccd1SDavid SchultzIEEE-like arithmetic, some explanation of struct FPI and the bits 294cc36ccd1SDavid Schultzarray may be helpful. Both gdtoa and strtodg operate on a bits array 295cc36ccd1SDavid Schultzdescribed by FPI *fpi. The bits array is of type ULong, a 32-bit 296cc36ccd1SDavid Schultzunsigned integer type. Floating-point numbers have fpi->nbits bits, 297cc36ccd1SDavid Schultzwith the least significant 32 bits in bits[0], the next 32 bits in 298cc36ccd1SDavid Schultzbits[1], etc. These numbers are regarded as integers multiplied by 299cc36ccd1SDavid Schultz2^e (i.e., 2 to the power of the exponent e), where e is the second 300cc36ccd1SDavid Schultzargument (be) to gdtoa and is stored in *exp by strtodg. The minimum 301cc36ccd1SDavid Schultzand maximum exponent values fpi->emin and fpi->emax for normalized 302cc36ccd1SDavid Schultzfloating-point numbers reflect this arrangement. For example, the 303cc36ccd1SDavid SchultzP754 standard for binary IEEE arithmetic specifies doubles as having 304cc36ccd1SDavid Schultz53 bits, with normalized values of the form 1.xxxxx... times 2^(b-1023), 305cc36ccd1SDavid Schultzwith 52 bits (the x's) and the biased exponent b represented explicitly; 306cc36ccd1SDavid Schultzb is an unsigned integer in the range 1 <= b <= 2046 for normalized 307cc36ccd1SDavid Schultzfinite doubles, b = 0 for denormals, and b = 2047 for Infinities and NaNs. 308cc36ccd1SDavid SchultzTo turn an IEEE double into the representation used by strtodg and gdtoa, 309cc36ccd1SDavid Schultzwe multiply 1.xxxx... by 2^52 (to make it an integer) and reduce the 310cc36ccd1SDavid Schultzexponent e = (b-1023) by 52: 311cc36ccd1SDavid Schultz 312cc36ccd1SDavid Schultz fpi->emin = 1 - 1023 - 52 313cc36ccd1SDavid Schultz fpi->emax = 1046 - 1023 - 52 314cc36ccd1SDavid Schultz 315cc36ccd1SDavid SchultzIn various wrappers for IEEE double, we actually write -53 + 1 rather 316cc36ccd1SDavid Schultzthan -52, to emphasize that there are 53 bits including one implicit bit. 317cc36ccd1SDavid SchultzField fpi->rounding indicates the desired rounding direction, with 318cc36ccd1SDavid Schultzpossible values 319cc36ccd1SDavid Schultz FPI_Round_zero = toward 0, 320cc36ccd1SDavid Schultz FPI_Round_near = unbiased rounding -- the IEEE default, 321cc36ccd1SDavid Schultz FPI_Round_up = toward +Infinity, and 322cc36ccd1SDavid Schultz FPI_Round_down = toward -Infinity 323cc36ccd1SDavid Schultzgiven in gdtoa.h. 324cc36ccd1SDavid Schultz 325cc36ccd1SDavid SchultzField fpi->sudden_underflow indicates whether strtodg should return 326cc36ccd1SDavid Schultzdenormals or flush them to zero. Normal floating-point numbers have 327cc36ccd1SDavid Schultzbit fpi->nbits in the bits array on. Denormals have it off, with 328cc36ccd1SDavid Schultzexponent = fpi->emin. Strtodg provides distinct return values for normals 329cc36ccd1SDavid Schultzand denormals; see gdtoa.h. 330cc36ccd1SDavid Schultz 33184781d47SDavid SchultzCompiling g__fmt.c, strtod.c, and strtodg.c with -DUSE_LOCALE causes 33284781d47SDavid Schultzthe decimal-point character to be taken from the current locale; otherwise 33384781d47SDavid Schultzit is '.'. 33484781d47SDavid Schultz 335c88250a5SDavid SchultzPlease send comments to David M. Gay (dmg at acm dot org, with " at " 336c88250a5SDavid Schultzchanged at "@" and " dot " changed to "."). 337