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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
/*
* Copyright 2016 The Emscripten Authors. All rights reserved.
* Emscripten is available under two separate licenses, the MIT license and the
* University of Illinois/NCSA Open Source License. Both these licenses can be
* found in the LICENSE file.
*/
// For sincos
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char **argv) {
printf("PI:%.2f,%.2f,%d\n", M_PI, -M_PI, (1 / 0.0) > 1e300); // could end up as
// infinity, or just
// a very very big
// number
printf("inf:");
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);
printf("\n");
printf("div:");
div_t div_result = div(23, 10);
printf(",%d", div_result.quot);
printf(",%d", div_result.rem);
div_result = div(-5, 3); // see div manpage :)
printf(",%d", div_result.quot); // -1
printf(",%d", div_result.rem); // -2
div_result = div(5, -3);
printf(",%d", div_result.quot);
printf(",%d", div_result.rem);
div_result = div(-5, -3);
printf(",%d", div_result.quot);
printf(",%d", div_result.rem);
printf("\n");
{
printf("modf:");
double x,y;
x = modf(3.2, &y);
printf(",%1.1lf", x);
printf(",%1.1lf", y);
x = modf(-3.2, &y);
printf(",%1.1lf", x);
printf(",%1.1lf", y);
printf("\n");
}
{
printf("ldexp:");
printf(",%1.1f", ldexp(3.0f, 3));
printf(",%1.1lf", ldexpf(9.0, 5));
printf(",%1.1Lf", ldexpl(10.0l, 2));
printf("\n");
}
{
printf("modff:");
float x,y;
x = modff(3.2, &y);
printf(",%1.1f", x);
printf(",%1.1f", y);
x = modff(-3.2, &y);
printf(",%1.1f", x);
printf(",%1.1f", y);
printf("\n");
}
printf("trig:");
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;
}
|