Skip to content

Instantly share code, notes, and snippets.

@kahrl
Created December 3, 2015 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kahrl/d25242341d49ca45d961 to your computer and use it in GitHub Desktop.
Save kahrl/d25242341d49ca45d961 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <math.h>
#include <quadmath.h>
int main(void)
{
int n;
FILE *f1 = fopen("tgamma-double.txt", "w");
if (f1) {
for (n = -500; n <= 500; ++n) {
double x = n / 100.0;
double y = tgamma(x);
if (!isnan(y)) {
fprintf(f1, "%.16f %.16f\n", x, y);
}
}
fclose(f1);
}
FILE *f2 = fopen("tgamma-float128.txt", "w");
if (f2) {
for (n = -500; n <= 500; ++n) {
__float128 x = n / 100.0Q;
__float128 y = tgammaq(x);
if (!isnanq(y)) {
char buf[256];
quadmath_snprintf(buf, sizeof buf, "%.33Qf", x);
fputs(buf, f2);
fputc(' ', f2);
quadmath_snprintf(buf, sizeof buf, "%.33Qf", y);
fputs(buf, f2);
fputc('\n', f2);
}
}
fclose(f2);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment