Problems? Is your data what you think it is?  
PerlMonks 
Comment on 
( #3333=superdoc: print w/ replies, xml )  Need Help?? 
0^{0}Defining 0^{0}=1 is a good idea, because it makes the easy things easy and the hard things possible. For instance, the binomial theorem says(a+b)^{n} = ∑_{k=0}^{n} C_{k,n} a^{k}b^{nk},where C_{k,n}=n!/(k!(nk)!) is the binomial coefficient. Only to you, it doesn't. Because when n=0, a=0 and b!=0, the left hand side is defined but the right hand side isn't. Of course, if you agreed that 0^{0}=1 then the right hand side would be defined and you'd have equality. Or take the exponential function: exp(x) = ∑_{n=0}^{∞} x^{n}/n!(and similar expansions for sin and cos, not to mention any other Taylor expansion). This requires you to believe that 0!=0^{0}=1, or you'll have trouble reading the first term (which always uses 0!), and if x=0 you'll also have a 0^{0} there. Or believing that a^{m+n} = a^{m}a^{n} (when a=0, m=n). It all requires you to believe that 0^{0}=1, or spend the rest of your life writing down pointless special cases. Why is /0 an error?So if 0^{0}=1 for convenience, why do I refuse to accept a more "convenient" behaviour of division by zero  return undef instead of an error?Because the error is more convenient! First, note that there's no "convenient" value to return for x/0, ever. Which is why CheeseLord wants to get back the nonnumeric undef. Which might be nice for $a=$b/$c. Except that then you have to test for defined($a) afterwards, where previously you'd test for $c==0 beforehand. Next, there's the problem of implicit conversion of undef to 0 in numeric expressions. We certainly don't want 5+17/0 == 5 (and if you still think we do, do you also want 1/0 < 1/10?) So we'd have to do something more clever about undef in numerical operations, say having all results undef in the presence of an undef operand. Apart from probably being slower (a wellworn excuse, and not particularly convincing by now), you still have to test your return value to see if it's undef. And you get significantly less information about the precise source of the undef (although with Perl6 attributes, perhaps you could get more information in such a case). How does And, of course, such "propogated undef" semantics break every existing line of Perl... So here's a challenge for anyone (CheeseLord or otherwise) who'd like to have ! defined(x/0) in Perl, along with "propogated undef": show some code that is clearer to express with these semantics than in the present case. In reply to Re: More Fun with Zero!
by ariels

