You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The attribute :attr:`sys.float_info.dig` needs further explanation. If
340
+
``s`` is any string representing a decimal number with at most
341
+
:attr:`sys.float_info.dig` significant digits, then converting ``s`` to a
342
+
float and back again will recover a string representing the same decimal
343
+
value::
332
344
333
-
.. note::
345
+
>>> import sys
346
+
>>> sys.float_info.dig
347
+
15
348
+
>>> s = '3.14159265358979' # decimal string with 15 significant digits
349
+
>>> format(float(s), '.15g') # convert to float and back -> same value
350
+
'3.14159265358979'
351
+
352
+
But for strings with more than :attr:`sys.float_info.dig` significant digits,
353
+
this isn't always true::
334
354
335
-
The information in the table is simplified.
355
+
>>> s = '9876543211234567' # 16 significant digits is too many!
356
+
>>> format(float(s), '.16g') # conversion changes value
357
+
'9876543211234568'
336
358
337
359
.. versionadded:: 2.6
338
360
@@ -992,3 +1014,8 @@ always available.
992
1014
first three characters of :const:`version`. It is provided in the :mod:`sys`
993
1015
module for informational purposes; modifying this value has no effect on the
994
1016
registry keys used by Python. Availability: Windows.
1017
+
1018
+
.. rubric:: Citations
1019
+
1020
+
.. [C99] ISO/IEC 9899:1999. "Programming languages -- C." A public draft of this standard is available at http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf .
0 commit comments