Lines Matching refs:fraction
43 sign, intpart, fraction, exppart = res.group(1,2,3,4)
46 if fraction: fraction = fraction[1:]
49 return sign, intpart, fraction, expo
51 def unexpo(intpart, fraction, expo): argument
54 f = len(fraction)
55 intpart, fraction = intpart + fraction[:expo], fraction[expo:]
60 intpart, fraction = intpart[:expo], intpart[expo:] + fraction
62 fraction = '0'*(-expo-i) + fraction
63 return intpart, fraction
65 def roundfrac(intpart, fraction, digs): argument
67 f = len(fraction)
69 return intpart, fraction + '0'*(digs-f)
73 total = intpart + fraction
85 intpart, fraction = total[:i], total[i:]
87 return intpart, fraction[:digs]
97 sign, intpart, fraction, expo = extract(x)
100 intpart, fraction = unexpo(intpart, fraction, expo)
101 intpart, fraction = roundfrac(intpart, fraction, digs)
104 if digs > 0: return sign + intpart + '.' + fraction
112 sign, intpart, fraction, expo = extract(x)
114 while fraction and fraction[0] == '0':
115 fraction = fraction[1:]
117 if fraction:
118 intpart, fraction = fraction[0], fraction[1:]
124 intpart, fraction = intpart[0], intpart[1:] + fraction
126 intpart, fraction = roundfrac(intpart, fraction, digs)
128 intpart, fraction, expo = \
129 intpart[0], intpart[1:] + fraction[:-1], \
132 if digs > 0: s = s + '.' + fraction