How does float.as_integer_ratio() work in python3?

Viewed 113

I was reading the documentation of Python3.4 and came across a method 'as_integer_ratio' (This method is defined for python2.7 also).

The documentation says, 'Return a pair of integers whose ratio is exactly equal to the original float and with a positive denominator. Raises OverflowError on infinities and a ValueError on NaNs."

I tried for 56.9, and the output was:

>>> b = 56.9
>>> b.as_integer_ratio()
(8007963087418163, 140737488355328)
>>>

Out of curiosity, any idea regarding how these values are getting calculated? The values could also have been (569, 10), right? Or am I missing something trivial?

0 Answers
Related