Skip to content

Commit 5969d2f

Browse files
committed
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.
1 parent 2d6f853 commit 5969d2f

10 files changed

Lines changed: 1764 additions & 3 deletions

File tree

Include/floatobject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ PyAPI_FUNC(void) PyFloat_AsString(char*, PyFloatObject *v);
8686
PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le);
8787
PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le);
8888

89+
/* Used to get the important decimal digits of a double */
90+
PyAPI_FUNC(int) _PyFloat_Digits(char *buf, double v, int *signum);
91+
PyAPI_FUNC(void) _PyFloat_DigitsInit(void);
92+
8993
/* The unpack routines read 4 or 8 bytes, starting at p. le is a bool
9094
* argument, true if the string is in little-endian format (exponent
9195
* last, at p+3 or p+7), false if big-endian (exponent first, at p).

0 commit comments

Comments
 (0)