> 13 авг. 2019 г., в 0:39, Konstantin Osipov написал(а): > > * 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. It wouldn’t slow down hint calculation (timing difference is tiny). It will slow down decimal comparison with doubles and integers, though. We will get faster comparison for decimals that differ in first 2-5 fractional digits at the cost of having to cast every double and int to decimal for comparison with decimals. Is this worth it? > > Is decimalRescale optimized to be a no-op if there is no need to > rescale? Yes > > -- > Konstantin Osipov, Moscow, Russia -- Serge Petrenko sergepetrenko@tarantool.org