develooper Front page | perl.perl5.porters | Postings from July 2001

Re: [DOC PATCH bleadperl] detypo Math::BigInt docs

Thread Previous | Thread Next
July 10, 2001 18:56
Re: [DOC PATCH bleadperl] detypo Math::BigInt docs
Message ID:


John Peacock wrote:
>Philip Newton wrote:
>> On the other hand, if a/b==c, then b*c == a. This holds for 10/5==2 -->
>> 5*2==10, but not if you posit 0/0==0, since 0*0==0, but 5*0==0 as well,
>> so one could argue that 0/0 should be 5. This argument holds for any
>> possible result. So if 0/0 has any one value, it has to be one that's
>> specially defined; NaN makes sense to me for this.
>> (And what do you think is 0**0? 0**n == 0 for all positive n, but n**0
>> == 1 for all positive n.... Presumably, 0**0 is also NaN, then.)

>I pulled out "What Every Computer Scientist Should Know About Floating-
>Point Arithmetic" (ACM Computing Surveys, Vol 23, No 1, March 1991) and
>checked what it says (based on IEEE 745 & 854):
>         0/0 ==  NaN 
>         1/0 ==  inf  
>        -1/0 == -inf
>        -0   == +0

Ah, good ;)

>Indeed, there is a discussion of signed zero and its importance in 
>maintaining sign.  Only when testing like "if (x==0)" is the sign of 
>zero ignored.  For example, IEEE 754 defines:
>        log 0 = -inf 
>and     log x is NaN for x < 0
>so if x is a small negative number that has underflowed to 0, we can
>report that log x is NaN because the sign did not disappear when
>the underflow occurred.

Only if you get underflows, which you never get with BigInt.

>As for what 0**0 should be, I can find no mention of it.  There is a

It is 1. Knuth and others mention it. I never knew about it until Mark
Dickinson send me an email explaining it:

(Of course, the decision that 0^0=1 is just a convention, but here are
some arguments for using this convention with your BigInts:

Mark wrote:
#Reasons for 0^0=1:  (1) Knuth thinks so.  (2) perl integers behave this
#way (3) if m, n>=0 then m^n is the number of distinct mappings from a set
#with m elements to a set with n elements;  there is exactly one map from
#the empty set to the empty set. (4) various theorems break down without
#this:  for example the binomial theorem states that (e.g. for n >= 2) 
#  (x+y)^n = x^0 y^n + n x^1 y^(n-1) + n(n-1)/2 x^2 y^(n-2) + ... 
#                                          + n x^(n-1) y^1 + x^n y^0
#for any value of x and y.  Put x = 0, y = 1 and you get 1 on the left hand
#side and 0^0 on the right.)

So I changed it (if you had read my changelog ;)

HTH Tels

- -- 
perl -MMath::String -e 'print \
Math::String->from_number("215960156869840440586892398248"),"\n"'     Thief - The Dark Project       My current Perl projects       Fight for your right to link.
 PGP key available on or via email 

Version: 2.6.3i
Charset: latin1


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