This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question on valid transformations for cbrt
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 01 Apr 2004 16:22:30 -0800
- Subject: Re: Question on valid transformations for cbrt
- References: <200403061854.i26Isn2m018933@caip.rutgers.edu><Pine.LNX.4.44.0403070640560.29012-100000@www.eyesopen.com>
Roger Sayle <roger@eyesopen.com> writes:
> i.e. cbrt(-29.7) = -3.1 but pow(-29.7,1.0/3.0) => EDOM.
one reason for this is because 1.0 / 3.0, as a double, gets rounded to
6004799503160661 / 2 ^ 54, and so the result of the pow() is imaginary
and not representable as a 'double'. (If we'd used base-3 arithmetic,
pow() could always provide a result with negative inputs.)
(This also means the same transformations with sqrt() will usually be
safe.)
--
- Geoffrey Keating <geoffk@geoffk.org>