public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: Jan Hubicka <jh@suse.cz>
Cc: Richard Henderson <rth@redhat.com>, gcc-patches@gcc.gnu.org, aj@suse.de
Subject: Re: Converting floor to rint
Date: Thu, 07 Nov 2002 01:33:00 -0000	[thread overview]
Message-ID: <m3smydvi3z.fsf@soliton.integrable-solutions.net> (raw)
In-Reply-To: Jan Hubicka's message of "Thu, 7 Nov 2002 10:21:12 +0100"

Jan Hubicka <jh@suse.cz> writes:

| > Jan Hubicka <jh@suse.cz> writes:
| > 
| > | On the related note.  How bad would you consider converting
| > | floor(x) into rint(x-0.5) in the fast-math mode?
| > 
| > If you think you do want to do that transformation, then I would
| > prefer this
| > 
| >   floor(x) -> nearbyint(x-0.5)
| > 
| > | That transformation would do a miracles for i386, where rint is faster
| > | than floor by quite a lot and should suffice for 3D application in
| > | reliablility.  I can imagine it to fail only for very large numbers...
| > 
| > Not really.  floor(1) == 1 and rint(1 - 0.5) maybe be 0 or 1 depending
| > on the current rounding mode.
| Hmm, is rint really expected to be dependent on the rouding mode?
| Man page claims:
|        The nearbyint functions round their argument to an integer value
|        in floating point format, using the current
|        rounding direction and without raising the inexact
|        exception.
| 
|        The rint functions do the same, but will raise the
|        inexact exception when the result differs in  value
|        from the argument.

The C definition says:

       7.12.9.3  The nearbyint functions

       Synopsis

       [#1]

               #include <math.h>
               double nearbyint(double x);
               float nearbyintf(float x);
               long double nearbyintl(long double x);

       Description

       [#2]  The  nearbyint  functions  round  their argument to an
       integer value in floating-point format,  using  the  current
       rounding  direction  and  without  raising  the  ``inexact''
       floating-point exception.

       Returns

       [#3] The nearbyint  functions  return  the  rounded  integer
       value.

       7.12.9.4  The rint functions

       Synopsis

       [#1]

               #include <math.h>
               double rint(double x);
               float rintf(float x);
               long double rintl(long double x);

       Description

       [#2]  The rint functions differ from the nearbyint functions
       (7.12.9.3) only in that the rint  functions  may  raise  the
       ``inexact''  floating-point  exception if the result differs
       in value from the argument.

       Returns

       [#3] The rint functions return the rounded integer value.

| I can builtinize nearbyint too if it makes sense.

Do we have framework to deal correctly with current rounding mode?
I not, I would say, leave it as is until we have the appropriate
machinery. 

| I am bit confused by
| rint.  Does it imply that rint will raise exception for any non-integral
| arugment?

And depending on the rounding mode.

-- Gaby

  parent reply	other threads:[~2002-11-07  9:33 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-05  9:14 Simplify floating point conversions Jan Hubicka
2002-11-05  9:38 ` Richard Henderson
2002-11-05  9:42   ` Jan Hubicka
2002-11-06  1:23   ` Simplify floating point conversions II Jan Hubicka
2002-11-06  3:08     ` Michael Matz
2002-11-06  4:36       ` Jan Hubicka
2002-11-06  9:54     ` Jan Hubicka
2002-11-06 10:09       ` Richard Henderson
2002-11-06 13:11         ` Jan Hubicka
2002-11-06 13:19           ` Jan Hubicka
2002-11-06 13:35           ` Gabriel Dos Reis
2002-11-06 13:36             ` Jan Hubicka
2002-11-06 14:06               ` Gabriel Dos Reis
2002-11-06 14:29             ` Converting floor to rint Jan Hubicka
2002-11-06 14:47               ` Richard Henderson
2002-11-06 14:53                 ` Jan Hubicka
2002-11-06 14:55               ` Gabriel Dos Reis
2002-11-07  1:21                 ` Jan Hubicka
2002-11-07  1:32                   ` Jakub Jelinek
2002-11-07  1:33                   ` Gabriel Dos Reis [this message]
2002-11-07  1:44                     ` Jan Hubicka
2002-11-07  1:52                       ` Jakub Jelinek
2002-11-07  1:54                         ` Jan Hubicka
2002-11-07  2:04                     ` Jan Hubicka
2002-11-07  4:47                       ` Gabriel Dos Reis
2002-11-07  4:56                         ` Jan Hubicka
2002-11-07  5:14                           ` Andreas Schwab
2002-11-07  5:27                             ` Gabriel Dos Reis
2002-11-07  5:31                               ` Jan Hubicka
2002-11-07  5:35                                 ` Andreas Schwab
2002-11-07  5:22                           ` Gabriel Dos Reis
2002-11-07  5:43                             ` Andreas Schwab
2002-11-07  6:23                               ` Gabriel Dos Reis
2002-11-07  7:01                                 ` Jan Hubicka
2002-11-07  7:18                                   ` Gabriel Dos Reis
2002-11-06 13:48         ` Simplify floating point conversions III Jan Hubicka
2002-11-06 14:55           ` Richard Henderson
2002-11-07  2:54             ` Simplify floating point conversions IV Jan Hubicka
2002-11-18 15:01               ` Richard Henderson
2002-11-05 11:14 ` Simplify floating point conversions Geoff Keating
2002-11-06  1:09   ` Jan Hubicka

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=m3smydvi3z.fsf@soliton.integrable-solutions.net \
    --to=gdr@integrable-solutions.net \
    --cc=aj@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jh@suse.cz \
    --cc=rth@redhat.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).