develooper Front page | perl.vmsperl | Postings from June 2002

Re: [PATCH] pp.c:pp_pow() -- quit when you're done

Thread Previous | Thread Next
Nicholas Clark
June 16, 2002 08:10
Re: [PATCH] pp.c:pp_pow() -- quit when you're done
Message ID:
On Sun, Jun 16, 2002 at 04:06:51PM +0200, Philip Newton wrote:
> On Sun, 16 Jun 2002 12:45:30 +0100, (Nicholas Clark)
> wrote:
> > For information (which I don't think has reached p5p) the reason for having
> > messy loops in pp_pow rather than using pow() or log(), exp() and a multiply
> > is that on Irix with longdoubles, 2**31 was giving a floating point value
> > slightly *less* than 1<<31, which was really screwing up some tests.
> > (and by implication (nearly) every perl programmer's assumption that 2**n
> > is an integer)
> Perhaps it had the same floating-point engine as my first "scientific"

Elbonian? :-)

> calculator, for which 2**32 was 4294967295 (i.e. one less than the
> correct answer).

Well, it did round like that, because the answer the C library gave back
was something like 2147483647.999999999999999 - so close to 2147483648 that
it stringified as "2147483648" but when converted to an IV truncated down to
The stringifying behaviour meant that it took a while to work out what was
actually going on.

Nicholas Clark
Even better than the real thing:

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