Tarantool development patches archive
 help / color / mirror / Atom feed
From: Mergen Imeev <imeevma@tarantool.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: tml <tarantool-patches@dev.tarantool.org>,
	Alexander Turenko <alexander.turenko@tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH 2/5] box/sql: func -- fix compilation warning
Date: Mon, 18 May 2020 14:13:07 +0300	[thread overview]
Message-ID: <20200518111306.GA12861@tarantool.org> (raw)
In-Reply-To: <20200518101502.117121-3-gorcunov@gmail.com>

On Mon, May 18, 2020 at 01:14:59PM +0300, Cyrill Gorcunov wrote:
> The @r is "double" value thus use explicit
> conversion to placate clang compiler.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>  src/box/sql/func.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/box/sql/func.c b/src/box/sql/func.c
> index 2c510940b..d5463facd 100644
> --- a/src/box/sql/func.c
> +++ b/src/box/sql/func.c
> @@ -845,9 +845,9 @@ roundFunc(sql_context * context, int argc, sql_value ** argv)
>  	 * handle the rounding directly,
>  	 * otherwise use printf.
>  	 */
> -	if (n == 0 && r >= 0 && r < LARGEST_INT64 - 1) {
> +	if (n == 0 && r >= 0 && r < (double)(LARGEST_INT64 - 1)) {
>  		r = (double)((sql_int64) (r + 0.5));
I am not sure that this change worth to do since
LARGEST_INT64 = 2^63 -1 and
(double)(LARGEST_INT64 - 1) == 2^63, if I am not wrong.
I also not sure that this worked right before.
I think it makes sense to compare with someting like 2^53,
because if absolute value of r is greater that 2^53 than
we do not have to round it anymore.
 
> -	} else if (n == 0 && r < 0 && (-r) < LARGEST_INT64 - 1) {
> +	} else if (n == 0 && r < 0 && (-r) < (double)(LARGEST_INT64 - 1)) {
>  		r = -(double)((sql_int64) ((-r) + 0.5));
>  	} else {
>  		const char *rounded_value = tt_sprintf("%.*f", n, r);
> -- 
> 2.26.2
> 

  reply	other threads:[~2020-05-18 11:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18 10:14 [Tarantool-patches] [PATCH 0/5] build: " Cyrill Gorcunov
2020-05-18 10:14 ` [Tarantool-patches] [PATCH 1/5] test: unit/guava -- " Cyrill Gorcunov
2020-05-18 10:14 ` [Tarantool-patches] [PATCH 2/5] box/sql: func " Cyrill Gorcunov
2020-05-18 11:13   ` Mergen Imeev [this message]
2020-05-18 11:32     ` Cyrill Gorcunov
2020-05-18 10:15 ` [Tarantool-patches] [PATCH 3/5] box/sql: vdbe " Cyrill Gorcunov
2020-05-18 10:15 ` [Tarantool-patches] [PATCH 4/5] box/sql: vdbemem " Cyrill Gorcunov
2020-05-18 10:15 ` [Tarantool-patches] [PATCH 5/5] box/vynil: quota -- fix compilation waning Cyrill Gorcunov
2020-05-19 12:33   ` Nikita Pettik
2020-10-01 12:07 ` [Tarantool-patches] [PATCH 0/5] build: fix compilation warning Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200518111306.GA12861@tarantool.org \
    --to=imeevma@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 2/5] box/sql: func -- fix compilation warning' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox