author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Thu, 16 Apr 2009 12:49:11 +0200 | |
changeset 39 | 46d7ec9d63bd |
parent 29 | 7abf6146898e |
child 63 | 5a82f89d607e |
permissions | -rw-r--r-- |
/** * test/demos/floating.c * Copyright (C) 2008 Markus Broeker */ #include <stdio.h> #include <stdlib.h> #include <math.h> double *getValues (int elements) { double *values; int i; if ((values = calloc (elements + 1, sizeof (double))) == NULL) return NULL; for (i = elements; i >= 0; i--) values[i] = cos (i); return values; } #define MAX 40 int main (int argc, char **argv) { double *values = getValues (MAX); int i; for (i = 0; i < MAX; i++) { if (fabs (cos (i) - values[i]) < 0.001) printf ("COS(%d) = %3.2g = %3.2g\n", i, values[i], cos (i)); } if (values != NULL) free (values); return EXIT_SUCCESS; }