Mail Archives: djgpp/1998/01/25/04:49:01
On Sat, 24 Jan 1998, Jeff Taylor wrote:
> For pow(1.000336, -5) I get Infinity. Is this outside the range of
> pow?
> For gamma(5) I get 3.178, I'm expecting 24. Are there two functions
> called gamma functions?
The most probably cause for this seemingly strange behavior is that you
fail to include <math.h>. This leaves GCC with no prototype of `pow' and
`gamma', and so it doesn't convert the integer values like 5 and -5 into
doubles, which is what these functions expect. This can certainly produce
some weird results, and even crash your program.
You should always include <math.h> when you work with math functions. I
would also suggest to use double constants, like 5.0 and -5.0, instead of
integers. This could save you hours of debugging in some cases.
- Raw text -