diff --git a/mapytex/calculus/API/tokens/number.py b/mapytex/calculus/API/tokens/number.py index 8a03731..d321291 100644 --- a/mapytex/calculus/API/tokens/number.py +++ b/mapytex/calculus/API/tokens/number.py @@ -16,6 +16,7 @@ from ...core.arithmetic import gcd from ...core.random.int_gene import filter_random from ...core.MO import MO, MOnumber from ...core.MO.fraction import MOFraction +from random import random __all__ = ["Integer", "Decimal"] @@ -242,6 +243,20 @@ class Fraction(Token): def denominator(self): return self._mo.denominator + @property + def decimal(self): + """ return decimal approximation of the fraction + + :example: + >>> f = Fraction("3/4") + >>> f.decimal + + >>> f = Fraction("1/3") + >>> f.decimal + + """ + return Decimal(_Decimal(self._mo.numerator._value) / _Decimal(self._mo.denominator._value)) + # ----------------------------- # Reglages pour 'vim'