Issue #7092: Fix the DeprecationWarnings emitted by the standard library
[python.git] / Doc / library / fpformat.rst
blob3448585609920d44f9c5d49f187155b824f6df78
2 :mod:`fpformat` --- Floating point conversions
3 ==============================================
5 .. module:: fpformat
6    :synopsis: General floating point formatting functions.
7    :deprecated:
9 .. deprecated:: 2.6
10     The :mod:`fpformat` module has been removed in Python 3.0.
12 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
15 The :mod:`fpformat` module defines functions for dealing with floating point
16 numbers representations in 100% pure Python.
18 .. note::
20    This module is unnecessary: everything here can be done using the ``%`` string
21    interpolation operator described in the :ref:`string-formatting` section.
23 The :mod:`fpformat` module defines the following functions and an exception:
26 .. function:: fix(x, digs)
28    Format *x* as ``[-]ddd.ddd`` with *digs* digits after the point and at least one
29    digit before. If ``digs <= 0``, the decimal point is suppressed.
31    *x* can be either a number or a string that looks like one. *digs* is an
32    integer.
34    Return value is a string.
37 .. function:: sci(x, digs)
39    Format *x* as ``[-]d.dddE[+-]ddd`` with *digs* digits after the  point and
40    exactly one digit before. If ``digs <= 0``, one digit is kept and the point is
41    suppressed.
43    *x* can be either a real number, or a string that looks like one. *digs* is an
44    integer.
46    Return value is a string.
49 .. exception:: NotANumber
51    Exception raised when a string passed to :func:`fix` or :func:`sci` as the *x*
52    parameter does not look like a number. This is a subclass of :exc:`ValueError`
53    when the standard exceptions are strings.  The exception value is the improperly
54    formatted string that caused the exception to be raised.
56 Example::
58    >>> import fpformat
59    >>> fpformat.fix(1.23, 1)
60    '1.2'