Module fpformat
[hide private]
[frames] | no frames]

Module fpformat

General floating point formatting functions.

Functions: fix(x, digits_behind) sci(x, digits_behind)

Each takes a number or a string and a number of digits as arguments.

Parameters: x: number to be formatted; or a string resembling a number digits_behind: number of digits behind the decimal point

Classes [hide private]
NotANumber
Functions [hide private]
 
extract(s)
Return (sign, intpart, fraction, expo) or raise an exception: sign is '+' or '-' intpart is 0 or more digits beginning with a nonzero fraction is 0 or more digits expo is an integer
 
unexpo(intpart, fraction, expo)
Remove the exponent by changing intpart and fraction.
 
roundfrac(intpart, fraction, digs)
Round or extend the fraction to size digs.
 
fix(x, digs)
Format x as [-]ddd.ddd with 'digs' digits after the point and at least one digit before.
 
sci(x, digs)
Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point and exactly one digit before.
 
test()
Interactive test run.
Variables [hide private]
  decoder = re.compile(r'^([-\+]?)0*(\d*)((?:\.\d*)?)(([eE][-\+]...

Imports: re


Function Details [hide private]

fix(x, digs)

 

Format x as [-]ddd.ddd with 'digs' digits after the point and at least one digit before. If digs <= 0, the point is suppressed.

sci(x, digs)

 

Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point and exactly one digit before. If digs is <= 0, one digit is kept and the point is suppressed.


Variables Details [hide private]

decoder

Value:
re.compile(r'^([-\+]?)0*(\d*)((?:\.\d*)?)(([eE][-\+]?\d+)?)$')