aboutsummaryrefslogtreecommitdiff
path: root/tests/core/test_math.in
blob: e638404b5533306e75eb4dd55366a8b16f1d23d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
int main(int argc, char **argv) {
  printf("*%.2f,%.2f,%d", M_PI, -M_PI, (1 / 0.0) > 1e300);  // could end up as
                                                            // infinity, or just
                                                            // a very very big
                                                            // number
  printf(",%d", isfinite(NAN) != 0);
  printf(",%d", isfinite(INFINITY) != 0);
  printf(",%d", isfinite(-INFINITY) != 0);
  printf(",%d", isfinite(12.3) != 0);
  printf(",%d", isinf(NAN) != 0);
  printf(",%d", isinf(INFINITY) != 0);
  printf(",%d", isinf(-INFINITY) != 0);
  printf(",%d", isinf(12.3) != 0);
  div_t div_result = div(23, 10);
  printf(",%d", div_result.quot);
  printf(",%d", div_result.rem);
  double sine = -1.0, cosine = -1.0;
  sincos(0.0, &sine, &cosine);
  printf(",%1.1lf", sine);
  printf(",%1.1lf", cosine);
  float fsine = -1.0f, fcosine = -1.0f;
  sincosf(0.0, &fsine, &fcosine);
  printf(",%1.1f", fsine);
  printf(",%1.1f", fcosine);
  fsine = sinf(1.1 + argc - 1);
  fcosine = cosf(1.1 + argc - 1);
  printf(",%1.1f", fsine);
  printf(",%1.1f", fcosine);
  printf("*\n");
  return 0;
}