From 4d6ef1da29e5c1bf4c2216d9fe0c14dcab0f04cd Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 13 Jan 2020 18:16:01 +0100 Subject: eliminate libtalerwire --- src/util/amount.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/util/amount.c') diff --git a/src/util/amount.c b/src/util/amount.c index 21410c769..edb9dc060 100644 --- a/src/util/amount.c +++ b/src/util/amount.c @@ -672,4 +672,25 @@ TALER_amount_divide (struct TALER_Amount *result, } +/** + * Round the amount to something that can be + * transferred on the wire. + * + * @param[in,out] amount amount to round down + * @return #GNUNET_OK on success, #GNUNET_NO if rounding was unnecessary, + * #GNUNET_SYSERR if the amount or currency was invalid + */ +int +TALER_amount_round (struct TALER_Amount *amount) +{ + uint32_t delta; + + delta = amount->fraction % (TALER_AMOUNT_FRAC_BASE / 100); + if (0 == delta) + return GNUNET_NO; + amount->fraction -= delta; + return GNUNET_OK; +} + + /* end of amount.c */ -- cgit v1.2.3