|
@ -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 |
|
|
|
|
|