public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Martin Jambor <mjambor@suse.cz>
Cc: Tejas Joshi <tejasjoshi9673@gmail.com>, <gcc-patches@gcc.gnu.org>,
	<hubicka@ucw.cz>
Subject: Re: [PATCH] Builtin function roundeven folding implementation
Date: Thu, 22 Aug 2019 15:52:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.21.1908221426570.27000@digraph.polyomino.org.uk> (raw)
In-Reply-To: <ri6ftlte12y.fsf@suse.cz>

On Thu, 22 Aug 2019, Martin Jambor wrote:

> +/* Round X to nearest integer, rounding halfway cases towards even.  */
> +
> +void
> +real_roundeven (REAL_VALUE_TYPE *r, format_helper fmt,
> +		const REAL_VALUE_TYPE *x)
> +{
> +  if (is_halfway_below (x))
> +  {
> +    do_add (r, x, &dconsthalf, x->sign);
> +    if (!is_even (r))
> +      do_add (r, r, &dconstm1, x->sign);

I'm concerned that this would produce +0.0 for an argument of -0.5 (via 
-0.5 - 0.5 - -1.0 producing +0.0) when it needs to produce -0.0.

Note that testcases for the sign of zero results need to check e.g. 
!!__builtin_signbit on the result, or the result of calling 
__builtin_copysign* to extract the sign of the result, since 0.0 == -0.0 
so checking with ==, while necessary, is not sufficient in that case.

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2019-08-22 14:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28  3:40 Tejas Joshi
2019-07-29 16:49 ` Martin Jambor
2019-08-09 21:26 ` Joseph Myers
2019-08-14  7:24   ` Tejas Joshi
2019-08-21 11:52     ` Martin Jambor
2019-08-21 12:48       ` Joseph Myers
2019-08-21 19:10         ` Martin Jambor
2019-08-21 20:50           ` Joseph Myers
2019-08-22 14:40             ` Martin Jambor
2019-08-22 15:52               ` Joseph Myers [this message]
2019-08-22 21:39                 ` Tejas Joshi
2019-08-23 12:21                   ` Martin Jambor
2019-08-23 21:24                   ` Joseph Myers
2019-08-25 20:28                     ` Tejas Joshi
2020-02-12  6:20                     ` [PATCH] real: Fix roundeven on inf/nan [PR93663] Jakub Jelinek
2020-02-12 20:56                       ` Joseph Myers

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=alpine.DEB.2.21.1908221426570.27000@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=mjambor@suse.cz \
    --cc=tejasjoshi9673@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).