Python‎ > ‎Fraction‎ > ‎

Fraction.limit_denominator()


Definition
The method limit the denominator value of Fraction.

Syntax
Fraction(x).limit_denominator(y)

Parameters
x=Decimal point
y=number in format(10000)


Examples
Here are returns:
 >>> Fraction(2.1113003933).limit_denominator(1000)
Fraction(1233, 584)
>>> Fraction(2.11130032211111933).limit_denominator(100)
Fraction(19, 9)
>>> Fraction(2.111300).limit_denominator(1)
Fraction(2, 1)
>>> Fraction(2.1113003933).limit_denominator(1000)
Fraction(1233, 584)
>

___eq___
The return is following:
>> Fraction(2.11130032211111933).limit_denominator(100).__eq__(Fraction(2.1113003933).
limit_denominator(1000))
False

The return is:
 >>> Fraction(2.111300).limit_denominator(1).__eq__(Fraction(2, 1))
True

___truediv__
The equal to following returns:
 >>> Fraction(2.111300).limit_denominator(1).__truediv__(Fraction(2, 1))
Fraction(1, 1)

__sub__
The equation subtracted the value.
 >>> Fraction(2.111300).limit_denominator(1).__sub__(Fraction(2, 1))
Fraction(0, 1)

__add__
Fraction values are added.
 >>> Fraction(2.111300).limit_denominator(1).__add__(Fraction(2, 1))
Fraction(4, 1)

__mul__
The equal to following:
 >>> Fraction(2.111300).limit_denominator(1).__mul__(Fraction(2, 1))
Fraction(4, 1)

__gt__
The fraction are following:
 >>> Fraction(2.111300).limit_denominator(1).__gt__(Fraction(2, 1))
False

__ge__
The equal to:
 >>> Fraction(2.111300).limit_denominator(1).__ge__(Fraction(2, 1))
True

___le__
The equivalent to following output:
 >>> Fraction(2.111300).limit_denominator(1).__le__(Fraction(2, 1))
True

__lt__
The following are output:
 >>> Fraction(2.111300).limit_denominator(1).__lt__(Fraction(2, 1))
False
>>>


Comments