Recently, a correspondent mentioned float.as_integer_ratio(), new in Python 2.6, noting that typical floating point implementations are essentially rational approximations o
The algorithm used by as_integer_ratio only considers powers of 2 in the denominator. Here is a (probably) better algorithm.
as_integer_ratio