https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81630
Bug ID: 81630 Summary: powl returns values with insufficient accuracy Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: kakehi at waseda dot jp Target Milestone: --- Created attachment 41870 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41870&action=edit compare powl(t,N) with exp2l(N*log2l(t)) I calculated powl(t,N) where t= (N+1)/N, N: an integer value 2^n (n: positive integer) to get an approximation to Napier's constant. Here is some results: n powl(t, N) exp2l(N*log2l(t)) 25: 2.7182817879534639155837683e+00 2.7182817879534906457209692e+00 26: 2.7182818082062409458920377e+00 2.7182818082062676638861742e+00 27: 2.7182818183325918449770586e+00 2.7182818183326563803766523e+00 28: 2.7182818233957862993910304e+00 2.7182818233958507905551755e+00 29: 2.7182818259273639105617903e+00 2.7182818259274480086548631e+00 30: 2.7182818271931621957604452e+00 2.7182818271932466208488932e+00 31: 2.7182818278260525070993969e+00 2.7182818278261459278132700e+00 32: 2.7182818278260525070993969e+00 2.7182818281425955814038786e+00 33: 2.7182818278260525070993969e+00 2.7182818283008204083076031e+00 34: 2.7182818278260525070993969e+00 2.7182818283799328217594654e+00 35: 2.7182818278260525070993969e+00 2.7182818284194890285938168e+00 As you see, powl(t,N) values have saturated when n>30, where exp2l(N*log2l(t)), which is a formula mathematically equivalent to powl(t,N), produces increasing values in converging to Napier's constant. The values are obtained by the program "comparePow.c": #include <stdio.h> #include <stdlib.h> #include <math.h> /* checking the powl function. */ int main(int argc, char *argv[]){ if( argc==1 ){ printf("usage: $ comparePOW n [m]"); exit(-1);} int n= atoi(argv[1]), m; if( argc==2 ) m= n; else m= atoi(argv[2]); for(int i= n; i<=m; i++){ long double N=powl(2.0, (long double)i); if( N==N+1 ){ printf("too large N\n"); exit(-1); } long double t= (N+1)/N; long double powlx= powl(t,N); long double powly= exp2l(N*log2l(t)); printf("%3d: %.25Le %.25Le\n", i, powlx, powly); } return 0; } by running it with the command "./a.out 25 35". The command "gcc -v" produces: Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1 Apple LLVM version 8.1.0 (clang-802.0.42) Target: x86_64-apple-darwin16.7.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin