bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible error in bc


From: Andreas Schwab
Subject: Re: Possible error in bc
Date: Wed, 13 Feb 2002 17:46:20 +0100
User-agent: Gnus/5.090005 (Oort Gnus v0.05) Emacs/21.2.50 (ia64-suse-linux)

address@hidden (Hans-Bernhard Broeker) writes:

|> Harald Anlauf <address@hidden> wrote:
|> > address@hidden (Dean Allen Provins) writes:
|> 
|> >> It was my understanding (and I checked my CRC math tables book, and
|> >> also tried gcc in a simple test) that 0^0 should be 0 (zero).
|> 
|> > I don't know how you fouled gcc into this, but this is clearly wrong.
|> 
|> "Wrong" is bit strong.  0^0 is mathematically an undefined operation,
|> which can easily be seen from some approaches to computing it:
|> 
|>      (any other number but 0)^0 = 1
|>      0^(any positive number) = 0
|>      0^(any negative number) = infinity (or undefined, your choice)
|> 
|> So: which is it going to be?  Both 0 and 1 are commonly assumed in
|> some areas of mathematics.
|> 
|> And neither do you have to fould GCC to give such a result.  That's
|> entirely within the freedom of the C *library* implementor do decide
|> what the result is: The result of pow(0,0) is implementation-defined,
|> and it's not up to GCC to decide what it may be.

IEEE 559 makes pow(x,0) == 1 for every x (even NaN).

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]