cinap_lenrekadd hg and python4bb9e2215 years agoHistory
54 lines · 1.6 KB · TeX
RawDownload
\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 withfloating point numbers representations in 100\% purePython. \note{This module is unneeded: everything here couldbe done via the \code{\%} string interpolation operator.} The \module{fpformat} module defines the following functions and anexception:  \begin{funcdesc}{fix}{x, digs}Format \var{x} as \code{[-]ddd.ddd} with \var{digs} digits after thepoint 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 likeone. \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 likeone. \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 standardexceptions are strings.  The exception value is the improperlyformatted string that caused the exception to be raised.\end{excdesc} Example: \begin{verbatim}>>> import fpformat>>> fpformat.fix(1.23, 1)'1.2'\end{verbatim}