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

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

From:
Tels
Date:
July 10, 2001 18:56
Subject:
Re: [DOC PATCH bleadperl] detypo Math::BigInt docs
Message ID:
200107102251.f6AMpu914971@xena.tops.net
```-----BEGIN PGP SIGNED MESSAGE-----

Moin,

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.)

HTH Tels

- --
perl -MMath::String -e 'print \
Math::String->from_number("215960156869840440586892398248"),"\n"'

http://bloodgate.com/thief/     Thief - The Dark Project
http://bloodgate.com/perl       My current Perl projects
PGP key available on http://bloodgate.com/tels.asc or via email

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: latin1

iQEVAwUBO0uG+ncLPEOTuEwVAQElJAf/UvNv8qorWX5lDhJ+jqbB2hUw+wpmrYwJ
2D+xZX4Nvste/yWxozu5NLvukhe0wgTB/gAoBnr3/90GgwuJrEXhVROJx/PS6BpZ
qkGlgp++AJqINlrC4OkSHTi0Ql/GFdLv+KtyjcrtN04btNuLYUpAER8qlFCvZC38
mMKRXklEV9wxlG7EPo6aOVkMwwjwUm8W6o9H2Ha5DRCAGKgBv0bY8epiM5Mm08gA
2mqY/C9DehdxaHgLheAVo/DLEXW1CHGWCkTWLpBliHnAH7dYmMqLEfpz3AqkUYPi
MEGSJbfshwxA+E3hcIHvjMemdTnc1ZNN03ntozPuWQBy2a6OJ/cHFA==
=1RDZ
-----END PGP SIGNATURE-----

```