Fix bug in --numbers fixed in Python where results would not be rounded after division
This commit is contained in:
parent
cad1e324d9
commit
f724ae0b93
@ -46,6 +46,17 @@ class Fixed(BasePyNum):
|
|||||||
"""Overrides BasePyNum._to_impl"""
|
"""Overrides BasePyNum._to_impl"""
|
||||||
return decimal.Decimal(value).quantize(_quantize_exp)
|
return decimal.Decimal(value).quantize(_quantize_exp)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _truediv_impl(cls, i1, i2):
|
||||||
|
"""Implements BaseNum._truediv_impl"""
|
||||||
|
return (i1 / i2).quantize(_quantize_exp)
|
||||||
|
|
||||||
|
@compatible_types
|
||||||
|
def __itruediv__(self, other):
|
||||||
|
"""Overrides BaseNum.__itruediv__"""
|
||||||
|
self.impl = (self.impl / other.impl).quantize(_quantize_exp)
|
||||||
|
return self
|
||||||
|
|
||||||
def round(self, dps, mode):
|
def round(self, dps, mode):
|
||||||
"""Implements BaseNum.round"""
|
"""Implements BaseNum.round"""
|
||||||
return Fixed._from_impl(self.impl.quantize(decimal.Decimal('10') ** -dps, mode))
|
return Fixed._from_impl(self.impl.quantize(decimal.Decimal('10') ** -dps, mode))
|
||||||
|
Reference in New Issue
Block a user