author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Thu, 16 Apr 2009 12:49:12 +0200 | |
changeset 43 | cf8c1b5127b2 |
parent 29 | 7abf6146898e |
child 63 | 5a82f89d607e |
permissions | -rw-r--r-- |
0 | 1 |
/** |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
8
diff
changeset
|
2 |
* test/demos/floating.c |
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
8
diff
changeset
|
3 |
* Copyright (C) 2008 Markus Broeker |
0 | 4 |
*/ |
5 |
||
6 |
#include <stdio.h> |
|
7 |
#include <stdlib.h> |
|
8 |
#include <math.h> |
|
9 |
||
10 |
double *getValues (int elements) |
|
11 |
{ |
|
12 |
double *values; |
|
13 |
int i; |
|
14 |
||
15 |
if ((values = calloc (elements + 1, sizeof (double))) == NULL) |
|
16 |
return NULL; |
|
17 |
for (i = elements; i >= 0; i--) |
|
18 |
values[i] = cos (i); |
|
19 |
return values; |
|
20 |
} |
|
21 |
||
22 |
#define MAX 40 |
|
23 |
||
24 |
int main (int argc, char **argv) |
|
25 |
{ |
|
26 |
double *values = getValues (MAX); |
|
27
81a574d60c15
typo in min2time format string
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
9
diff
changeset
|
27 |
|
0 | 28 |
int i; |
29 |
||
30 |
for (i = 0; i < MAX; i++) { |
|
31 |
if (fabs (cos (i) - values[i]) < 0.001) |
|
32 |
printf ("COS(%d) = %3.2g = %3.2g\n", i, values[i], cos (i)); |
|
33 |
} |
|
34 |
||
35 |
if (values != NULL) |
|
36 |
free (values); |
|
8
96d16dfe787a
We use return EXIT_SUCCESS instead of return 0
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
37 |
|
0 | 38 |
return EXIT_SUCCESS; |
39 |
} |