diff options
author | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-03 11:25:13 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-03 11:25:13 +0000 |
commit | 458120dd40db6b4df55a4e96b650e16798ef06a0 (patch) | |
tree | 8f82685be24fef97e715c6f5ca4c68d34d5074ee /sys/src/cmd/python/Doc/lib/libfpformat.tex | |
parent | 3a742c699f6806c1145aea5149bf15de15a0afd7 (diff) |
add hg and python
Diffstat (limited to 'sys/src/cmd/python/Doc/lib/libfpformat.tex')
-rw-r--r-- | sys/src/cmd/python/Doc/lib/libfpformat.tex | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/sys/src/cmd/python/Doc/lib/libfpformat.tex b/sys/src/cmd/python/Doc/lib/libfpformat.tex new file mode 100644 index 000000000..a3a628223 --- /dev/null +++ b/sys/src/cmd/python/Doc/lib/libfpformat.tex @@ -0,0 +1,54 @@ +\section{\module{fpformat} --- + Floating point conversions} + +\declaremodule{standard}{fpformat} +\sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il} +\modulesynopsis{General floating point formatting functions.} + + +The \module{fpformat} module defines functions for dealing with +floating point numbers representations in 100\% pure +Python. \note{This module is unneeded: everything here could +be done via the \code{\%} string interpolation operator.} + +The \module{fpformat} module defines the following functions and an +exception: + + +\begin{funcdesc}{fix}{x, digs} +Format \var{x} as \code{[-]ddd.ddd} with \var{digs} digits after the +point and at least one digit before. +If \code{\var{digs} <= 0}, the decimal point is suppressed. + +\var{x} can be either a number or a string that looks like +one. \var{digs} is an integer. + +Return value is a string. +\end{funcdesc} + +\begin{funcdesc}{sci}{x, digs} +Format \var{x} as \code{[-]d.dddE[+-]ddd} with \var{digs} digits after the +point and exactly one digit before. +If \code{\var{digs} <= 0}, one digit is kept and the point is suppressed. + +\var{x} can be either a real number, or a string that looks like +one. \var{digs} is an integer. + +Return value is a string. +\end{funcdesc} + +\begin{excdesc}{NotANumber} +Exception raised when a string passed to \function{fix()} or +\function{sci()} as the \var{x} parameter does not look like a number. +This is a subclass of \exception{ValueError} when the standard +exceptions are strings. The exception value is the improperly +formatted string that caused the exception to be raised. +\end{excdesc} + +Example: + +\begin{verbatim} +>>> import fpformat +>>> fpformat.fix(1.23, 1) +'1.2' +\end{verbatim} |