Home | History | Annotate | Download | only in python2.7

Lines Matching refs:digs

64 def roundfrac(intpart, fraction, digs):
65 """Round or extend the fraction to size digs."""
67 if f <= digs:
68 return intpart, fraction + '0'*(digs-f)
70 if i+digs < 0:
71 return '0'*-digs, ''
73 nextdigit = total[i+digs]
75 n = i + digs - 1
85 if digs >= 0:
86 return intpart, fraction[:digs]
88 return intpart[:digs] + '0'*-digs, ''
90 def fix(x, digs):
91 """Format x as [-]ddd.ddd with 'digs' digits after the point
93 If digs <= 0, the point is suppressed."""
100 intpart, fraction = roundfrac(intpart, fraction, digs)
103 if digs > 0: return sign + intpart + '.' + fraction
106 def sci(x, digs):
107 """Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point
109 If digs is <= 0, one digit is kept and the point is suppressed."""
124 digs = max(0, digs)
125 intpart, fraction = roundfrac(intpart, fraction, digs)
131 if digs > 0: s = s + '.' + fraction
142 x, digs = input('Enter (x, digs): ')
143 print x, fix(x, digs), sci(x, digs)