This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: fabs(-0.0) and soft-float
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Aldy Hernandez <aldyh at redhat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 03 Oct 2002 02:46:02 -0300
- Subject: Re: fabs(-0.0) and soft-float
- Organization: GCC Team, Red Hat
- References: <20021003023916.GA22385@redhat.com>
On Oct 2, 2002, Aldy Hernandez <aldyh@redhat.com> wrote:
> Should we have gcc fold fabs() like this:?
> if (x > 0)
> x = x;
> else
> x = -x;
Nope, same problem for +0.0.
I can think of two possible solutions:
if (x < 0) x = - x;
else if (x == 0) x = 0;
or
if (x >= 0) x = +0.0 + x; // IIRC, +0.0 + -0.0 == +0.0
else x = -x;
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer