Exemplo n.º 1
0
int
main(void)
{
	double x;

	/* Random values, approx. -177.79..171.63 */
	x = tgamma(11.0);			/* (11 - 1)! */
	if (floor(x) != 3628800.0)
		errx(1, "tgamma(11.0) = %f", x);

	x = tgamma(3.5);			/* 15/8 * sqrt(pi) */
	if (floor(x * 100) != 332.0)
		errx(1, "tgamma(3.5) = %f", x);

	x = tgamma(-0.5);			/* -2 * sqrt(pi) */
	if (floor(x * 100) != -355.0)
		errx(1, "tgamma(-0.5) = %f", x);

	/* Special cases */
	x = tgamma(-1);				/* Negative integers */
	if (!_isnan(x))
		errx(1, "tgamma(-1) = %f", x);

	x = tgamma(-177.8);			/* x ~< -177.79 */
	if (x != 0)
		errx(1, "tgamma(-177.8) = %f", x);

	x = tgamma(171.64);			/* x ~> 171.63 */
	if (!_isinf(x))
		errx(1, "tgamma(171.64) = %f", x);

	x = tgamma(0.0);
	if (!_isinf(x) || x < 0)
		errx(1, "tgamma(0) = %f", x);

	x = tgamma(-0.0);
	if (!_isinf(x) || x > 0)
		errx(1, "tgamma(0) = %f", x);

	x = tgamma(-HUGE_VAL);
	if (!_isnan(x))
		errx(1, "tgamma(-HUGE_VAL) = %f", x);

	x = tgamma(HUGE_VAL);
	if (!_isinf(x))
		errx(1, "tgamma(HUGE_VAL) = %f", x);

#ifdef NAN
	x = tgamma(NAN);
	if (!_isnan(x))
		errx(1, "tgamma(NaN) = %f", x);
#endif

	return 0;
}
Exemplo n.º 2
0
int main (void)
{
  int i;

  if (_isinf(s_inf()) && _isinf(-s_inf()))
    printf("_isinf() test successful.\n");
  else
    printf("_isinf() test failed.\n");

  for (i = 0; i < 256; ++i)
  {
    if (_isnan(s_nan(i)) != 1)
    {
      printf("_isnan() test failed.\n");
      return 1;
    }
  }
  printf("_isnan() test successful.\n");
  return 0;
}
Exemplo n.º 3
0
int check_result(double src, double ref, double test, eps_t* thres)
{
  double diff;
  double error;

  diff=fabs(ref-test);
  if(ref==0)
    error=diff;
  else
    error=diff/fabs(ref);

  if (_isnan(error) || _isinf(error))
    return 1; //warning

  if(error>=thres->warn && error<thres->fail) {
    return 1; //warning
  }else if (error >= thres->fail) {
    printf("error=%12.5E src=%12.5E ref=%12.5E\t test=%12.5E\n", error, src, ref, test);
	return 2; //error
  }else{
    return 0; //pass
  }
}
Exemplo n.º 4
0
/*
 * @implemented
 */
int _finite( double x )
{
	return !_isinf(x);
}