0**0 relied on underlying C library for elder perls, which is mostly 0 but could be domain error.

Currently, as I see in source code, file "pp.c", integer power is implemented in C, and it happen to result in "1", either by accident or intentionally.

Here is code excerpt from perl-5.8.0 to demonstrate my point:

/* now we have integer ** positive integer. foo & (foo - 1) is zero only for a power of 2. */ if (!(baseuv & (baseuv - 1))) { /* We are raising power-of-2 to postive integer. The logic here will work for any base (even non +-integer bases) but it can be less accurate than pow (base,power) or exp (power * log (base)) wh +en the intermediate values start to spill out of the m +antissa. With powers of 2 we know this can't happen. And powers of 2 are the favourite thing for per +l programmers to notice ** not doing what they me +an. */ NV result = 1.0; NV base = baseuok ? baseuv : -(NV)baseuv; int n = 0; /* The logic is this. x ** n === x ** m1 * x ** m2 where n = m1 + m2 so as 42 is 32 + 8 + 2 x ** 42 can be written as x ** 32 * x ** 8 * x ** 2 I can calculate x ** 2, x ** 4, x ** 8 etc triv +ially: x ** 2n is x ** n * x ** n So I loop round, squaring x each time (x, x ** 2, x ** 4, x ** 8) and multiply the re +sult by the x-value whenever that bit is set in the +power. To finish as soon as possible I zero bits in th +e power when I've done them, so that power becomes zero + when I clear the last bit (no more to do), and the l +oop terminates. */

Courage, the Cowardly Dog


In reply to Re: 0**0 by Courage
in thread 0**0 by Juerd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.