develooper Front page | perl.perl5.porters | Postings from March 2013

Re: [perl #117315] [Win32, 5.17.10] infinity is zero

Thread Previous | Thread Next
Nicholas Clark
March 24, 2013 13:03
Re: [perl #117315] [Win32, 5.17.10] infinity is zero
Message ID:
On Sat, Mar 23, 2013 at 09:15:58PM -0700, Sisyphus wrote:

> I don't know if this bug was present in 5.17.9 (and/or earlier).
> It affects only my 64-bit build of 5.17.10. My 32-bit builds,
> including the 64int build, are fine.
> 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:

	SETn( Perl_pow( left, right) );

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>

main (int argc, char **argv) {
    double power = 1e16;
    printf("2**%g = %g\n", power, pow(2, power));
    return 0;

>   Compiler:
>     cc='x86_64-w64-mingw32-gcc', ccflags 
>  -DPERL_IMPLICIT_SYS -fno-strict-aliasing -mms-bitfields',
>     optimize='-s -O2',

Nicholas Clark

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About