• File: fpformat.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python27/lib64/python2.7/fpformat.pyc
  • Date Modified: 10/26/2026 8:10 PM
  • File size: 4.69 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

jc@sdZddlmZeddd[ddlZddd	gZejd
Zyd	efdYZWne	k
rdZnXd
Z
dZdZdZ
dZdZdS(s8General 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
i(twarnpy3ks2the fpformat module has been removed in Python 3.0t
stackleveliNtfixtscit
NotANumbers+^([-+]?)(\d*)((?:\.\d*)?)(([eE][-+]?\d+)?)$cBseZRS((t__name__t
__module__(((s-/opt/alt/python27/lib64/python2.7/fpformat.pyRssfpformat.NotANumbercCstj|}|d	kr't|n|jdddd\}}}}|jd}|dkrod}n|r|d}n|rt|d}nd}||||fS(
sReturn (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 integeriiiit0t+tiN(tdecodertmatchtNoneRtgrouptlstriptint(tstrestsigntintparttfractiontexpparttexpo((s-/opt/alt/python27/lib64/python2.7/fpformat.pytextract#s$	
cCs|dkrUt|}||| ||}}||kr|d||}qnW|dkrt|}|| |||}}||krd|||}qn||fS(s5Remove the exponent by changing intpart and fraction.iR(tlen(RRRtfti((s-/opt/alt/python27/lib64/python2.7/fpformat.pytunexpo3s
cCs[t|}||kr.||d||fSt|}||dkrYd|dfS||}|||}|dkr&||d}xH|dkr||dkrPn|d}qWd|}|d}d}|| tt||ddt||d}|| ||}}n|dkr@||| fS|| d|dfSdS(s*Round or extend the fraction to size digs.RiR	t5it9N(Rtchrtord(RRtdigsRRttotalt	nextdigittn((s-/opt/alt/python27/lib64/python2.7/fpformat.pyt	roundfracAs,


8cCst|tdkr't|}nyt|\}}}}Wntk
rW|SXt|||\}}t|||\}}x$|r|ddkr|d}qW|dkrd}n|dkr||d|S||SdS(sFormat x as [-]ddd.ddd with 'digs' digits after the point
    and at least one digit before.
    If digs <= 0, the point is suppressed.R	iRit.N(ttypetreprRRRR$(txR RRRR((s-/opt/alt/python27/lib64/python2.7/fpformat.pyR[s
	cCst|tdkr't|}nt|\}}}}|sx.|ru|ddkru|d}|d}qHW|r|d|d}}|d}qd}n-|t|d}|d|d|}}td|}t|||\}}t|dkrB|d|d|d |t|d}}}n||}|dkri|d|}ntt|}ddt||}|dkrd|}n
d	|}|d
|S(sFormat 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.R	iRiiR%it-Rte(R&R'RRtmaxR$tabs(R(R RRRRRR*((s-/opt/alt/python27/lib64/python2.7/fpformat.pyRks6

	


cCsZy<x5td\}}|Gt||Gt||GHqWWnttfk
rUnXdS(sInteractive test run.sEnter (x, digs): N(tinputRRtEOFErrortKeyboardInterrupt(R(R ((s-/opt/alt/python27/lib64/python2.7/fpformat.pyttests'(t__doc__twarningsRtret__all__tcompileR
t
ValueErrorRt	TypeErrorRRR$RRR0(((s-/opt/alt/python27/lib64/python2.7/fpformat.pyt<module>s