diff --git a/compiler/runtime.ml b/compiler/runtime.ml index 1471757e..49a91c94 100644 --- a/compiler/runtime.ml +++ b/compiler/runtime.ml @@ -101,7 +101,8 @@ let money_to_cents m = m let money_round (m : money) : money = let units, cents = Z.div_rem m (Z.of_int 100) in (* If [m] is negative, [cents] will also be negative. *) - if Z.(abs cents < of_int 50) then units else Z.(units + of_int (sign units)) + if Z.(abs cents < of_int 50) then Z.(units * of_int 100) + else Z.((units + of_int (sign units)) * of_int 100) let decimal_of_string (d : string) : decimal = Q.of_string d let decimal_to_float (d : decimal) : float = Q.to_float d diff --git a/french_law/python/src/catala.py b/french_law/python/src/catala.py index 57cefcf8..2f817d44 100644 --- a/french_law/python/src/catala.py +++ b/french_law/python/src/catala.py @@ -369,9 +369,9 @@ def money_to_cents(m: Money) -> Integer: def money_round(m: Money) -> Money: res, remainder = t_divmod(m, 100) if remainder < 50: - res + return res * 100 else: - res + sign(res) + return (res + sign(res)) * 100 # -------- # Decimals