mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-09 01:35:56 +03:00
Fix wrong round definitions in runtime
This commit is contained in:
parent
f312c6bc6a
commit
a3e9dfa534
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user