This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question on valid transformations for cbrt


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>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]