Fraction(1.2) vs Fraction('1.2')

Viewed 35

When I use the Fraction class from fractions module

from fractions import Fraction
Fraction(1.2)

gives,

Fraction(5404319552844595, 4503599627370496)

whereas,

Fraction('1.2')

gives,

Fraction(6, 5)

notice that,

5404319552844595/4503599627370496

gives 1.2 as output.

Then shouldn't both give Fraction(6, 5) as output.

0 Answers
Related