[Pythonmac-SIG] Finding repeating decimals

Josh English english@spiritone.com
8 Oct 2002 08:21:10 -0700


Thanks for the help on this one. I am able to get this working now just
fine. The final code looks like this:

def DecToFraction(x):
	"""Returns a fraction object based on a decimal"""
	ipart = int(x)
	fpart = x-ipart
	y = 1.0/fpart
	y *= 10000
	f = Fraction(10000,int(y))
	f.reduce()
	f+=ipart
	return f

The Fraction class supports adding and mulitiplying between fractions
and integers. I need to incorporate adding and multiplying floats.

Thanks for the help
Josh English