Mercurial > cpython-lru_cache-weakref
diff Python/pystrtod.c @ 53618:4762394fc26c legacy-trunk
Remove format_float and use _PyOS_double_to_string instead.
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Wed, 29 Apr 2009 21:56:53 +0000 |
| parents | a3fcccee8957 |
| children | 1f00bc1d115a |
line wrap: on
line diff
--- a/Python/pystrtod.c Wed Apr 29 20:41:00 2009 +0000 +++ b/Python/pystrtod.c Wed Apr 29 21:56:53 2009 +0000 @@ -595,6 +595,20 @@ 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,
