Mercurial > cpython-lru_cache-weakref
diff Include/floatobject.h @ 44262:24749a380409 legacy-trunk
Backport of r59456:59458 from py3k to trunk
Issue #1580: New free format floating point representation based on "Floating-Point Printer Sample Code", by Robert G. Burger. For example repr(11./5) now returns '2.2' instead of '2.2000000000000002'.
Thanks to noam for the patch! I had to modify doubledigits.c slightly to support X64 and IA64 machines on Windows. I also added the new file to the three project files.
| author | Christian Heimes <christian@cheimes.de> |
|---|---|
| date | Mon, 10 Dec 2007 22:28:56 +0000 |
| parents | c218d1ac916e |
| children | 26384b8180c7 |
line wrap: on
line diff
--- a/Include/floatobject.h Mon Dec 10 20:42:53 2007 +0000 +++ b/Include/floatobject.h Mon Dec 10 22:28:56 2007 +0000 @@ -86,6 +86,10 @@ PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le); PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le); +/* Used to get the important decimal digits of a double */ +PyAPI_FUNC(int) _PyFloat_Digits(char *buf, double v, int *signum); +PyAPI_FUNC(void) _PyFloat_DigitsInit(void); + /* The unpack routines read 4 or 8 bytes, starting at p. le is a bool * argument, true if the string is in little-endian format (exponent * last, at p+3 or p+7), false if big-endian (exponent first, at p).
