mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Python runtime: Money division can simply use Integer division to remain rational
This is cleaner than referencing `mpq` explicitly, as it still returns a `Decimal` with full rational (non-floating) precision.
This commit is contained in:
parent
6c1963e7dd
commit
940485dca4
@ -151,7 +151,7 @@ class Money:
|
||||
|
||||
def __truediv__(self, other: 'Money') -> Decimal:
|
||||
if isinstance(other, Money):
|
||||
return Decimal(mpq(self.value.value, other.value.value))
|
||||
return self.value / other.value
|
||||
elif isinstance(other, Decimal):
|
||||
return self * (1. / other.value)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user