From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 13 Aug 2019 00:39:14 +0300 From: Konstantin Osipov Subject: Re: [PATCH v2 7/8] decimal: add conversions to (u)int64_t Message-ID: <20190812213914.GJ32337@atlas> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: To: Serge Petrenko Cc: vdavydov.dev@gmail.com, tarantool-patches@freelists.org List-ID: * Serge Petrenko [19/08/08 15:01]: > Update decNumber library, add methods to convert decimals to uint64_t > and int64_t, add unit tests. > Also replace decimal_round() function with decimal_round_with_mode() to > allow setting rounding mode. > We need to round with mode DEC_ROUND_DOWN in to_int64 conversions in > order to be consistent with double to int conversions. > It will be needed to compute hints for decimal fields. > > Prerequisite #4333 > --- > src/lib/core/decimal.c | 57 +++++++++++++++++++++++++++++-- > src/lib/core/decimal.h | 19 +++++++++++ > test/unit/decimal.c | 66 ++++++++++++++++++++++++++++++++++- > test/unit/decimal.result | 74 ++++++++++++++++++++++++++++++++++++++-- > third_party/decNumber | 2 +- > 5 files changed, 210 insertions(+), 8 deletions(-) > > diff --git a/src/lib/core/decimal.c b/src/lib/core/decimal.c > index 840aa5dfe..19b5096ed 100644 > --- a/src/lib/core/decimal.c > +++ b/src/lib/core/decimal.c > @@ -157,6 +157,45 @@ decimal_to_string(const decimal_t *dec) > return buf; > } > > +static decimal_t * > +decimal_to_integer(decimal_t *dec) Why do you think it's the best hint option? Why not keep 2-5 decimal digits in a hint, as most currencies use? Would it slow down the hing making process? You call decimalRescale anyway, it seems. Is decimalRescale optimized to be a no-op if there is no need to rescale? -- Konstantin Osipov, Moscow, Russia