Sender: M DOT A DOT Bukin AT inp DOT nsk DOT su To: djgpp AT delorie DOT com Subject: Re: math functions References: <34CA750A DOT 7715 AT cyber-quest DOT com> Reply-To: M DOT A DOT Bukin AT inp DOT nsk DOT su From: M DOT A DOT Bukin AT inp DOT nsk DOT su Date: 27 Jan 1998 13:26:23 +0600 In-Reply-To: Jeff Taylor's message of Sat, 24 Jan 1998 18:11:06 -0500 Message-Id: <20u3aq9y3k.fsf@Sky.inp.nsk.su> Lines: 38 Precedence: bulk Jeff Taylor writes: > The gamma and pow functions > are not giving me the answers I expect. > 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? I think, you forgot to include apropriate header files. Here is correct program (except for typos): --- #include #include int main (void) { printf ("%g\n", pow (1.000336, -5)); printf ("%g\n", gamma (5)); /* I get 3.17805 here. */ printf ("%g\n", exp (gamma (5))); /* This one gives 24. */ return 0; } --- One more thing -- I think it is not DJGPP specific, but a general C question, so comp.lang.c is more apropriate. To make it closer to DJGPP, try to remove `#include ' and run gcc with `-Wall' switch (and then always use -Wall for compiling your programs, let compiler catch your mistakes). BTW, I have not DJGPP references for libc, but man page on Unix here says that gamma(x) returns ln|GAMMA(x)|, where GAMMA is the mathematical gamma function (gamma is not in libc and may not be documented in DJGPP libc references).