[Bug libstdc++/48738] pow() fails to produce (some) subnormalized numbers with integer exponents

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Apr 23 09:21:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48738

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-23 09:20:46 UTC ---
Integer exponent powers are computed using

TYPE
NAME (TYPE x, int m)
{
  unsigned int n = m < 0 ? -m : m;
  TYPE y = n % 2 ? x : 1;
  while (n >>= 1)
    {
      x = x * x;
      if (n % 2)
        y = y * x;
    }
  return m < 0 ? 1/y : y;
}

or optimal power series expansion for constant exponents starting with
GCC 4.5.

ISTR the standard allows this.  You should use a double exponent to
use the real power function, pow (2., -1024.)



More information about the Gcc-bugs mailing list