8 void print_trig_stuff __P ((void));
13 CONST char str[] = "123.456";
14 double x,h,li,lr,a,lrr;
18 printf ("%g %g\n", x, pow (10.0, 3.0));
22 printf("sinh(2.0) = %g\n", x);
26 printf("sinh(3.0) = %g\n", x);
34 printf("atan2(3,2) = %g\n", a);
38 printf("pow(%g,4.0) = %g\n", h, lr);
46 printf("%g / exp(%g * 5) = %g\n", lrr, a, lr);
52 printf("%g + 5*log(%g) = %g\n", lrr, h, li);
54 printf("cos(%g) = %g, sin(%g) = %g\n", li, cos(li), li, sin(li));
56 x = drem(10.3435,6.2831852);
58 printf("drem(10.3435,6.2831852) = %g\n", x);
60 x = drem(-10.3435,6.2831852);
62 printf("drem(-10.3435,6.2831852) = %g\n", x);
64 x = drem(-10.3435,-6.2831852);
66 printf("drem(-10.3435,-6.2831852) = %g\n", x);
68 x = drem(10.3435,-6.2831852);
70 printf("drem(10.3435,-6.2831852) = %g\n", x);
73 printf("x%8.6gx\n", .5);
74 printf("x%-8.6gx\n", .5);
75 printf("x%6.6gx\n", .5);
78 double x = atof ("-1e-17-");
79 printf ("%g %c= %g %s!\n",
81 x == -1e-17 ? '=' : '!',
83 x == -1e-17 ? "Worked" : "Failed");
92 #define PI 3.14159265358979323846264338327
94 const double RAD[5] = { 0, PI/2, PI, (3*PI)/2, 2*PI };
95 const int DEG[5] = { 0, 90, 180, 360 };
97 #define PRINT_IT_1_ARG(_func, _arg, _value) \
98 (_value) = (_func)((_arg)); \
101 printf("%s = ERROR %s\n", #_func, strerror(errno)); \
103 printf("%s(%g) = %g\n", #_func, _arg, (_value)); \
105 #define PRINT_IT_2_ARG(_func, _arg1, _arg2, _value) \
106 (_value) = (_func)((_arg1),(_arg2)); \
109 printf("%s = ERROR %s\n", #_func, strerror(errno)); \
111 printf("%s(%g, %g) = %g\n", #_func, _arg1, _arg2, (_value)); \
114 DEFUN_VOID (print_trig_stuff)
116 double value, arg1, arg2;
119 puts ("\n\nMath Test");
121 errno = 0; /* automatically reset on error condition */
124 PRINT_IT_1_ARG (sin, RAD[i], value);
125 PRINT_IT_1_ARG (cos, RAD[i], value);
126 PRINT_IT_1_ARG (tan, RAD[i], value);
127 PRINT_IT_1_ARG (asin, RAD[i], value);
128 PRINT_IT_1_ARG (acos, RAD[i], value);
129 PRINT_IT_1_ARG (atan, RAD[i], value);
130 PRINT_IT_2_ARG (atan2, RAD[i], -RAD[i % 4], value);
135 PRINT_IT_1_ARG (exp, arg1, value);
136 PRINT_IT_1_ARG (log, arg1, value);
137 PRINT_IT_1_ARG (log10, arg1, value);
138 PRINT_IT_2_ARG (pow, arg1, arg2, value);
139 PRINT_IT_1_ARG (sqrt, arg1, value);
140 PRINT_IT_1_ARG (cbrt, arg1, value);
141 PRINT_IT_2_ARG (hypot, arg1, arg2, value);
142 PRINT_IT_1_ARG (expm1, arg1, value);
143 PRINT_IT_1_ARG (log1p, arg1, value);
144 PRINT_IT_1_ARG (sinh, arg1, value);
145 PRINT_IT_1_ARG (cosh, arg1, value);
146 PRINT_IT_1_ARG (tanh, arg1, value);
147 PRINT_IT_1_ARG (asinh, arg1, value);
148 PRINT_IT_1_ARG (acosh, arg1, value);
149 PRINT_IT_1_ARG (atanh, arg1, value);