-----Original Message----- From: Nicholas Clark Sent: Monday, March 25, 2013 12:03 AM > On Sat, Mar 23, 2013 at 09:15:58PM -0700, Sisyphus wrote: > > > > > Perl correctly evaluates 2**1e15 as infinity. > > But it evaluates 2**1e16 as 0. For exponents greater than 16, 0 > > is also returned. (This shows up in one of the > > t/op/sprintf2.t tests as a 'divide-by-zero' error.) > > The actual maths should be hitting this rather simple bit of pp.c: > > #else > SETn( Perl_pow( left, right) ); > #endif /* HAS_AIX_POWL_NEG_BASE_BUG */ > > > so the question is, does it end up somewhere else? Or does it get there, > but the C runtime is the problem? > > If you compile a C program with the same compiler flags as perl was built > with, do you get the same results? ie > > #include <math.h> > #include <stdio.h> > > int > main (int argc, char **argv) { > double power = 1e16; > printf("2**%g = %g\n", power, pow(2, power)); > return 0; > } Bugger .... yes, it's the same result - though the right-wrong threshold for the C program is 1e9 (instead of 1e15). I have a number of other C compilers on this box which, I think, use the very same C runtime. They all seem to do the right thing, so I'm thinking this is a bug in the particular compiler being used. Anyway ... sorry for the noise ... feel free to close the bug report. Cheers, RobThread Previous