lgammaf Function

Calculates the natural logarithm of the absolute value of gamma of the single-precision floating-point argument.

Include

<math.h>

Prototype

float lgammaf(float x);

Argument

x
value to evaluate the natural logarithm of the absolute value of gamma

Return Value

Returns the natural logarithm of the absolute value of gamma of the argument.

Remarks

A range error occurs if x is too large, and errno will be set to ERANGE.

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)
{
  float x, y;

  x = 0.5;
  y = lgammaf(x);
  if(errno)
    perror("Error");
  printf("The natural log of gamma of %f is %f\n", x, y);

  x = -0.75;
  y = lgammaf(x);
  if(errno)
    perror("Error");
  printf("The natural log of gamma of %f is %f\n", x, y);
}

Example Output

The natural log of gamma of 0.500000 is 0.572365
The natural log of gamma of -0.750000 is 1.575705