summaryrefslogtreecommitdiff
path: root/Python/pystrtod.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-04-29 21:56:53 +0000
committerMark Dickinson <dickinsm@gmail.com>2009-04-29 21:56:53 +0000
commitdf108ca324149ec4beceb880a7ac265679df1dff (patch)
treeeb47c4cfcd8df0dba144b672b77d816f6d69f542 /Python/pystrtod.c
parent92fcc9c9919b41a611b1dc084ad8f414f1e4278d (diff)
downloadcpython-git-df108ca324149ec4beceb880a7ac265679df1dff.tar.gz
Remove format_float and use _PyOS_double_to_string instead.
Diffstat (limited to 'Python/pystrtod.c')
-rw-r--r--Python/pystrtod.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index 2df4e3d0ad..30dd4e5394 100644
--- a/Python/pystrtod.c
+++ b/Python/pystrtod.c
@@ -595,6 +595,20 @@ PyOS_ascii_formatd(char *buffer,
return buffer;
}
+/* Precisions used by repr() and str(), respectively.
+
+ The repr() precision (17 significant decimal digits) is the minimal number
+ that is guaranteed to have enough precision so that if the number is read
+ back in the exact same binary value is recreated. This is true for IEEE
+ floating point by design, and also happens to work for all other modern
+ hardware.
+
+ The str() precision (12 significant decimal digits) is chosen so that in
+ most cases, the rounding noise created by various operations is suppressed,
+ while giving plenty of precision for practical use.
+
+*/
+
PyAPI_FUNC(void)
_PyOS_double_to_string(char *buf, size_t buf_len, double val,
char format_code, int precision,