Browse Source

actually working now

master
Mario Alegre 5 years ago
parent
commit
d550947590
  1. 11
      python/FracAndDec.py

11
python/FracAndDec.py

@ -1,10 +1,11 @@
import decimal import decimal
import fractions from fractions import Fraction as Frac
class Dec(decimal.Decimal): class Dec(decimal.Decimal):
def __Fraction__(self): def __new__(cls,value="0",context=None):
return self.__new__(self.numerator) / self.__new__(self.denominator) if isinstance(value, Frac):
return super().__new__(cls,value.numerator,context) / super().__new__(cls,value.denominator,context)
else:
return super().__new__(cls,value,context)
getcontext = decimal.getcontext getcontext = decimal.getcontext
Frac = fractions.Fraction

Loading…
Cancel
Save