annotate Doc/lib/libfpformat.tex @ 25838:8540887bcec6 2.2

Backport of 2.183: Fix memory leak in add_subclass() found by NealN with valgrind.
author Guido van Rossum <guido@python.org>
date Fri, 18 Oct 2002 13:42:21 +0000
parents 376ee174ecd0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10978
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 \section{\module{fpformat} ---
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2 Floating point conversions}
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
3
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
4 \declaremodule{standard}{fpformat}
15467
d7864345b1c8 Update Moshe Zadka's email address to one works and might last a while.
Fred Drake <fdrake@acm.org>
parents: 11614
diff changeset
5 \sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
10978
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
6 \modulesynopsis{General floating point formatting functions.}
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
7
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
8
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9 The \module{fpformat} module defines functions for dealing with
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10 floating point numbers representations in 100\% pure
20580
376ee174ecd0 Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents: 15467
diff changeset
11 Python. \note{This module is unneeded: everything here could
376ee174ecd0 Use the \note and \warning macros where appropriate.
Fred Drake <fdrake@acm.org>
parents: 15467
diff changeset
12 be done via the \code{\%} string interpolation operator.}
10978
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
13
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
14 The \module{fpformat} module defines the following functions and an
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
15 exception:
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
17
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
18 \begin{funcdesc}{fix}{x, digs}
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
19 Format \var{x} as \code{[-]ddd.ddd} with \var{digs} digits after the
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
20 point and at least one digit before.
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
21 If \code{\var{digs} <= 0}, the decimal point is suppressed.
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
22
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
23 \var{x} can be either a number or a string that looks like
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
24 one. \var{digs} is an integer.
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
25
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
26 Return value is a string.
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
27 \end{funcdesc}
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
28
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
29 \begin{funcdesc}{sci}{x, digs}
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
30 Format \var{x} as \code{[-]d.dddE[+-]ddd} with \var{digs} digits after the
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
31 point and exactly one digit before.
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
32 If \code{\var{digs} <= 0}, one digit is kept and the point is suppressed.
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
33
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
34 \var{x} can be either a real number, or a string that looks like
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
35 one. \var{digs} is an integer.
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
36
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
37 Return value is a string.
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
38 \end{funcdesc}
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
39
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
40 \begin{excdesc}{NotANumber}
11614
590272abe69c Document 1.5.2+ aspects of the NotANumber exception. (Note that this
Fred Drake <fdrake@acm.org>
parents: 10978
diff changeset
41 Exception raised when a string passed to \function{fix()} or
590272abe69c Document 1.5.2+ aspects of the NotANumber exception. (Note that this
Fred Drake <fdrake@acm.org>
parents: 10978
diff changeset
42 \function{sci()} as the \var{x} parameter does not look like a number.
590272abe69c Document 1.5.2+ aspects of the NotANumber exception. (Note that this
Fred Drake <fdrake@acm.org>
parents: 10978
diff changeset
43 This is a subclass of \exception{ValueError} when the standard
590272abe69c Document 1.5.2+ aspects of the NotANumber exception. (Note that this
Fred Drake <fdrake@acm.org>
parents: 10978
diff changeset
44 exceptions are strings. The exception value is the improperly
590272abe69c Document 1.5.2+ aspects of the NotANumber exception. (Note that this
Fred Drake <fdrake@acm.org>
parents: 10978
diff changeset
45 formatted string that caused the exception to be raised.
10978
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
46 \end{excdesc}
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
47
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
48 Example:
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
49
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
50 \begin{verbatim}
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
51 >>> import fpformat
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
52 >>> fpformat.fix(1.23, 1)
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
53 '1.2'
95d782815901 Documentation for the fpformat module by Moshe Zadka
Fred Drake <fdrake@acm.org>
parents:
diff changeset
54 \end{verbatim}