https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70299

            Bug ID: 70299
           Summary: pow(long double, int) gives more imprecise result than
                    pow(long double,long double) in c++03 mode
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: b7.10110111 at gmail dot com
  Target Milestone: ---

The following example program appears to get different results for different
overloads of std::pow(), even though all the parameters don't lose precision on
call:

#include <iostream>
#include <cmath>
#include <limits>

int main()
{
    std::cout.precision(std::numeric_limits<long double>::digits10+3); //
=max_digits10
    std::cout << "pow(long double, int) :        " << std::pow(10.L,-4823) <<
"\n";
    std::cout << "pow(long double, long double): " << std::pow(10.L,-4823.L) <<
"\n";
}

Its output in -std=c++03 mode:
pow(long double, int) :        1.00000000000000000288e-4823
pow(long double, long double): 1.00000000000000000005e-4823

And in -std=c++11 and -std=c++14 mode it's correct:
pow(long double, int) :        1.00000000000000000005e-4823
pow(long double, long double): 1.00000000000000000005e-4823

Reply via email to