[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible error in bc
From: |
Hans-Bernhard Broeker |
Subject: |
Re: Possible error in bc |
Date: |
12 Feb 2002 11:34:29 GMT |
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. Or did you assume he
actually wrote 0^0? Which in C means an exclusive OR operation, and
should return 0.
--
Hans-Bernhard Broeker (address@hidden)
Even if all the snow were burnt, ashes would remain.