Feat: dirty way to get decimal approx of a function
This commit is contained in:
parent
2d296cf1d2
commit
43fd46379c
@ -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
|
||||
<Decimal 0.75>
|
||||
>>> f = Fraction("1/3")
|
||||
>>> f.decimal
|
||||
<Decimal 0.3333333333333333333333333333>
|
||||
"""
|
||||
return Decimal(_Decimal(self._mo.numerator._value) / _Decimal(self._mo.denominator._value))
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
|
Loading…
Reference in New Issue
Block a user