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

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

Thread Previous | Thread Next
John Peacock
July 10, 2001 14:15
Re: [DOC PATCH bleadperl] detypo Math::BigInt docs
Message ID:
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

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.

As for what 0**0 should be, I can find no mention of it.  There is a
table of operations that produce NaN's and exponent is not one of them.  
All of the rules above derive from taking the limit of small numbers 
going to 0, but I cannot work that out in my head right now (end of 
the day haze ;~).



John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747

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