From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9C54F4429E1 for ; Thu, 11 Jun 2020 23:30:56 +0300 (MSK) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) From: Chris Sosnin In-Reply-To: Date: Thu, 11 Jun 2020 23:30:55 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <5E6B336C-D827-4334-8633-D0FF654A029D@tarantool.org> References: <473ff051ab9075f28732c28396d4465460e4a130.1591371404.git.k.sosnin@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 2/2] Add IsWhole method for checking the fractional part of a number List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Thank you for the review! > On 11 Jun 2020, at 20:06, Vladislav Shpilevoy = wrote: >=20 > I guess you rather need name IsInt. 'Whole' has a different > meaning. You can say =E2=80=9Cwhole number=E2=80=9D =E2=80=94 a number without = decimal part. But IsInt sounds better, I agree. >=20 > 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=E2=80=99t 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=E2=80=99t perform = the check cause of decimal_to_integer call, decNumber ones require = context (these also don=E2=80=99t really check for zero-decimal part =E2=80= =94 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.