[Tarantool-patches] [PATCH 2/2] Add IsWhole method for checking the fractional part of a number

Chris Sosnin k.sosnin at tarantool.org
Thu Jun 11 23:30:55 MSK 2020


Thank you for the review!

> On 11 Jun 2020, at 20:06, Vladislav Shpilevoy <v.shpilevoy at tarantool.org> wrote:
> 
> I guess you rather need name IsInt. 'Whole' has a different
> meaning.

You can say “whole number” — a number without decimal part.
But IsInt sounds better, I agree.

> 
> Why do you need it, btw? Why decNumberToInt64() and decNumberToUInt64()
> are not enough? The only usecase for this new function I can
> imagine is an attempt to shrink a decimal value into a normal integer.
> Which are either int64_t or uint64_t.

In case of doubles sqlVdbeIntValue returns 0 if an argument has no decimal part (and doesn’t overflow) and not 0 otherwise, but it always modifies a pointer to an integer, because some functions may still use the result of conversion. So I tried to make the behavior the same.

decimal_to_* functions always trim the value and don’t perform the check cause of decimal_to_integer call, decNumber ones require context (these also don’t really check for zero-decimal part — instead comparing exponent with 0, making 1.000 a bad argument), so we need new wrappers which will do almost the same thing but with an extra check.



More information about the Tarantool-patches mailing list