tgammal Function

Calculates the gamma function of a long double precision floating-point argument.

Attention: This function is not implemented by MPLAB XC8 C compilers.

Include

<math.h>

Prototype

long double tgammal(long double x);

Argument

x
value for which to evaluate the gamma function

Return Value

Calculates the gamma function of the argument.

Remarks

If x is negative or if the result cannot be represented with x is zero, a domain error will occur and errno will be set to EDOM.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

#include <math.h>
#include <stdio.h>
#include <errno.h>

int main(void)
{
  long double x, y;

  x = 0.5;
  y = tgammal(x);
  if(errno)
    perror("Error");
  printf("The gamma function of %Lf is %Lf\n", x, y);

  x = -0.75;
  y = tgammal(x);
  if(errno)
    perror("Error");
  printf("The gamma function of %Lf is %Lf\n", x, y);
}

Example Output

The gamma function of 0.500000 is 1.772454
The gamma function of -0.750000 is -4.834147