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

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

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
March 24, 2013 13:03
Subject:
Re: [perl #117315] [Win32, 5.17.10] infinity is zero
Message ID:
20130324130332.GC3729@plum.flirble.org
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:

#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;
}


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

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About