1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
8 // ----------------------------------------------------------------------------
11 #define __MATH_H __MATH_H
13 // ----------------------------------------------------------------------------
16 #define HUGE_VAL // TODO
17 #define HUGE_VALF // TODO
18 #define HUGE_VALL // TODO
20 #define INFINITY // TODO
23 #define FP_FAST_FMA // TODO
24 #define FP_FAST_FMAF // TODO
25 #define FP_FAST_FMAL // TODO
27 #define FP_INFINITE // TODO
28 #define FP_NAN // TODO
29 #define FP_NORMAL // TODO
30 #define FP_SUBNORMAL // TODO
31 #define FP_ZERO // TODO
33 #define FP_ILOGB0 // TODO
34 #define FP_ILOGBNAN // TODO
37 #define MATH_ERREXCEPT 2
38 #define math_errhandling // TODO
40 // --------------------------------------------------------------------------
43 typedef double_t; // TODO
44 typedef float_t; // TODO
46 // --------------------------------------------------------------------------
51 #define isgreater( x, y ) // TODO
52 #define isgreaterequal( x, y ) // TODO
53 #define isless( x, y ) // TODO
54 #define islessequal( x, y ) // TODO
55 #define islessgreater( x, y ) // TODO
56 #define isunordered( x, y ) // TODO
57 #define fpclassify( x ) // TODO
58 #define isfinite( x ) // TODO
60 #define isinf( x ) // TODO
61 #define isnan( x ) // TODO
62 #define isnormal( x ) // TODO
63 #define signbit( x ) // TODO
67 // The same functionality as above is implemented as functions in C++.
68 bool signbit( float x );
69 bool signbit( double x );
70 bool signbit( long double x );
71 int fpclassify( float x );
72 int fpclassify( double x );
73 int fpclassify( long double x );
74 bool isfinite( float x );
75 bool isfinite( double x );
76 bool isfinite( long double x );
77 bool isinf( float x );
78 bool isinf( double x );
79 bool isinf( long double x );
80 bool isnan( float x );
81 bool isnan( double x );
82 bool isnan( long double x );
83 bool isnormal( float x );
84 bool isnormal( double x );
85 bool isnormal( long double x );
86 bool isgreater( float x, float y );
87 bool isgreater( double x, double y );
88 bool isgreater( long double x, long double y );
89 bool isgreaterequal( float x, float y );
90 bool isgreaterequal( double x, double y );
91 bool isgreaterequal( long double x, long double y );
92 bool isless( float x, float y );
93 bool isless( double x, double y );
94 bool isless( long double x, long double y );
95 bool islessequal( float x, float y );
96 bool islessequal( double x, double y );
97 bool islessequal( long double x, long double y );
98 bool islessgreater( float x, float y );
99 bool islessgreater( double x, double y );
100 bool islessgreater( long double x, long double y );
101 bool isunordered( float x, float y );
102 bool isunordered( double x, double y );
103 bool isunordered( long double x, long double y );
105 #endif // __cplusplus
107 // --------------------------------------------------------------------------
112 // These functions return the magnitude of their parameter.
113 double abs( double x );
114 float abs( float x );
115 long double abs( long double x );
116 float fabs( float x );
117 long double fabs( long double x );
119 // These functions return the sine of their parameter.
120 float sin( float x );
121 long double sin( long double x );
123 // These functions return the hyperbolic sine of their parameter.
124 float sinh( float x );
125 long double sinh( long double x );
127 // These functions return the arcsine of their parameter.
128 float asin( float x );
129 long double asin( long double x );
131 // These functions compute the arc hyperbolic sine of x.
132 float asinh( float x );
133 long double asinh( long double x );
135 // These functions return the cosine of their parameter.
136 float cos( float x );
137 long double cos( long double x );
139 // These functions return the hyperbolic cosine of their parameter.
140 float cosh( float x );
141 long double cosh( long double x );
143 // These functions return the arcsine of their parameter.
144 float acos( float x );
145 long double acos( long double x );
147 // These functions return the hyperbolic arccosine of their parameter.
148 float acosh( float x );
149 long double acosh( long double x );
151 // These functions return the tangent of their parameter.
152 float tan( float x );
153 long double tan( long double x );
155 // These functions return the hyperbolic tangent of their parameter.
156 float tanh( float x );
157 long double tanh( long double x );
159 // These functions return the arctangent of their parameter.
160 float atan( float x );
161 long double atan( long double x );
163 // These functions return the hyperbolic arctangent of their parameter.
164 float atanh( float x );
165 long double atanh( long double x );
168 float atan2( float y, float x );
169 long double atan2( long double y, long double x );
171 // These functions return sqrt( x^2 + y^2 ).
172 float hypot( float x, float y );
173 long double hypot( long double x, long double y );
175 // These functions return their parameter x, raised to the power y.
176 float pow( float x, float y );
177 long double pow( long double x, long double y );
178 double pow( double x, int y );
179 float pow( float x, int y );
180 long double pow( long double x, int y );
182 // These functions return the square root of their parameter.
183 float sqrt( float x );
184 long double sqrt( long double x );
187 float cbrt( float x );
188 long double cbrt( long double x );
191 float exp( float x );
192 long double exp( long double x );
195 float exp2( float x );
196 long double exp2( long double x );
199 float expm1( float x );
200 long double expm1( long double x );
203 float frexp( float x, int * exponent );
204 long double frexp( long double x, int * exponent );
207 float ldexp( float x, int exponent );
208 long double ldexp( long double x, int exponent );
210 // These functions return the natural logarithm of their parameter.
211 float log( float x );
212 long double log( long double x );
214 // These functions return the logarithm (base 10 ) of their parameter.
215 float log10( float x );
216 long double log10( long double x );
218 // These functions return the logarithm (base 2 ) of their parameter.
219 float log2( float x );
220 long double log2( long double x );
223 float logb( float x );
224 long double logb( long double x );
227 int ilogb( float x );
228 int ilogb( long double x );
231 float log1p( float x );
232 long double log1p( long double x );
234 // These functions return the smallest integer no larger than their parameter
235 float ceil( float x );
236 long double ceil( long double x );
238 // These functions return the biggest integer no larger than their parameter.
239 float floor( float x );
240 long double floor( long double x );
243 float fmod( float x, float y );
244 long double fmod( long double x, long double y );
247 float modf( float x, float * integer );
248 long double modf( long double x, long double * integer );
250 // These functions return their parameter x, with the sign of parameter y.
251 float copysign( float x, float y );
252 long double copysign( long double x, long double y );
255 float erf( float x );
256 long double erf( long double x );
259 float erfc( float x );
260 long double erfc( long double x );
263 float fdim( float x, float y );
264 long double fdim( long double x, long double y );
267 float fma( float x, float y, float z );
268 long double fma( long double x, long double y, long double z );
270 // These functions return the larger of their parameters.
271 float fmax( float x, float y );
272 long double fmax( long double x, long double y );
274 // These functions return the smaller of their parameters.
275 float fmin( float x, float y );
276 long double fmin( long double x, long double y );
279 long long llrint( float x );
280 long long llrint( long double x );
281 long lrint( float x );
282 long lrint( long double x );
283 float rint( float x );
284 long double rint( long double x );
287 long long llround( float x );
288 long long llround( long double x );
289 long lround( float x );
290 long lround( long double x );
291 float round( float x );
292 long double round( long double x );
295 float trunc( float x );
296 long double trunc( long double x );
299 float nearbyint( float x );
300 long double nearbyint( long double x );
303 float nextafter( float x, float y );
304 long double nextafter( long double x, long double y );
307 float nexttoward( float x, long double y );
308 long double nexttoward( long double x, long double y );
311 float remainder( float x, float y );
312 long double remainder( long double x, long double y );
315 float remquo( float x, float y, int * quotient );
316 long double remquo( long double x, long double y, int * quotient );
319 float scalbn( float x, int ex );
320 long double scalbn( long double x, int ex );
323 float scalbln( float x, long ex );
324 long double scalbln( long double x, long ex );
327 float lgamma( float x );
328 long double lgamma( long double x );
331 float tgamma( float x );
332 long double tgamma( long double x );
334 #endif // __cplusplus
336 // ----------------------------------------------------------------------------
337 // FUNCTIONS - Standard C
339 // These functions return the magnitude of their parameter.
340 double fabs( double x );
341 float fabsf( float x );
342 long double fabsl( long double x );
344 // These functions compute the sine of x (measured in radians).
345 double sin( double x );
346 float sinf( float x );
347 long double sinl( long double x );
349 // These functions return the hyperbolic cosine of their parameter.
350 double sinh( double x );
351 float sinhf( float x );
352 long double sinhl( long double x );
354 // These functions return the arcsine of their parameter.
355 double asin( double x );
356 float asinf( float x );
357 long double asinl( long double x );
359 // These functions return the hyperbolic arcsine of their parameter.
360 double asinh( double x );
361 float asinhf( float x );
362 long double asinhl( long double x );
364 // These functions compute the cosine of x (measured in radians).
365 double cos( double x );
366 float cosf( float x );
367 long double cosl( long double x );
369 // These functions return the hyperbolic cosine of their parameter.
370 double cosh( double x );
371 float coshf( float x );
372 long double coshl( long double x );
374 // These functions return the arccosine of their parameter.
375 double acos( double x );
376 float acosf( float x );
377 long double acosl( long double x );
379 // These functions return the hyperbolic arccosine of their parameter.
380 double acosh( double x );
381 float acoshf( float x );
382 long double acoshl( long double x );
384 // These functions return the tangent of x.
385 double tan( double x );
386 float tanf( float x );
387 long double tanl( long double x );
389 // These functions return the hyperbolic tangent of their parameter.
390 double tanh( double x );
391 float tanhf( float x );
392 long double tanhl( long double x );
394 // These functions compute the arctangent of x.
395 double atan( double x );
396 float atanf( float x );
397 long double atanl( long double x );
399 // These functions return the hyperbolic arctangent of their parameter.
400 double atanh( double x );
401 float atanhf( float x );
402 long double atanhl( long double x );
405 double atan2( double y, double x );
406 float atan2f( float y, float x );
407 long double atan2l( long double y, long double x );
409 // These functions return sqrt(x^2 + y^2 ).
410 double hypot( double x, double y );
411 float hypotf( float x, float y );
412 long double hypotl( long double x, long double y );
414 // These functions return their parameter x, raised to the power y.
415 double pow( double x, double y );
416 float powf( float x, float y );
417 long double powl( long double x, long double y );
419 // These functions return the square root of their parameter.
420 double sqrt( double x );
421 float sqrtf( float x );
422 long double sqrtl( long double x );
425 double cbrt( double x );
426 float cbrtf( float x );
427 long double cbrtl( long double x );
430 double exp( double x );
431 float expf( float x );
432 long double expl( long double x );
435 double exp2( double x );
436 float exp2f( float x );
437 long double exp2l( long double x );
440 double expm1( double x );
441 float expm1f( float x );
442 long double expm1l( long double x );
445 double frexp( double x, int * exp );
446 float frexpf( float x, int * exp );
447 long double frexpl( long double x, int * exp );
450 double ldexp( double x, int exp );
451 float ldexpf( float x, int exp );
452 long double ldexpl( long double x, int exp );
454 // These functions return the natural logarithm of their parameter.
455 double log( double x );
456 float logf( float x );
457 long double logl( long double x );
459 // These functions return the logarithm (base 10 ) of their parameter.
460 double log10( double x );
461 float log10f( float x );
462 long double log10l( long double x );
464 // These functions return the logarithm (base 2 ) of their parameter.
465 double log2( double x );
466 float log2f( float x );
467 long double log2l( long double x );
470 double logb( double x );
471 float logbf( float x );
472 long double logbl( long double x );
475 int ilogb( double x );
476 int ilogbf( float x );
477 int ilogbl( long double x );
480 double log1p( double x );
481 float log1pf( float x );
482 long double log1pl( long double x );
484 // These functions return the smallest integer no smaller than value.
485 double ceil( double x );
486 float ceilf( float x );
487 long double ceill( long double x );
489 // These functions return the largest integer no larger than their parameter.
490 double floor( double x );
491 float floorf( float x );
492 long double floorl( long double x );
495 double fmod( double x, double y );
496 float fmodf( float x, float y );
497 long double fmodl( long double x, long double y );
500 double modf( double x, double * integer );
501 float modff( float x, float * integer );
502 long double modfl( long double x, long double * integer );
504 // These functions return their parameter x, with the sign of parameter y.
505 double copysign( double x, double y );
506 float copysignf( float x, float y );
507 long double copysignl( long double x, long double y );
510 double erf( double x );
511 float erff( float x );
512 long double erfl( long double x );
515 double erfc( double x );
516 float erfcf( float x );
517 long double erfcl( long double x );
520 double fdim( double x, double y );
521 float fdimf( float x, float y );
522 long double fdiml( long double x, long double y );
525 double fma( double x, double y, double z );
526 float fmaf( float x, float y, float z );
527 long double fmal( long double x, long double y, long double z );
529 // These functions return the larger of their parameters.
530 double fmax( double x, double y );
531 float fmaxf( float x, float y );
532 long double fmaxl( long double x, long double y );
534 // These functions return the smaller of their parameters.
535 double fmin( double x, double y );
536 float fminf( float x, float y );
537 long double fminl( long double x, long double y );
540 long long llrint( double x );
541 long long llrintf( float x );
542 long long llrintl( long double x );
543 long lrint( double x );
544 long lrintf( float x );
545 long lrintl( long double x );
546 double rint( double x );
547 float rintf( float x );
548 long double rintl( long double x );
551 long long llround( double x );
552 long long llroundf( float x );
553 long long llroundl( long double x );
554 long lround( double x );
555 long lroundf( float x );
556 long lroundl( long double x );
557 double round( double x );
558 float roundf( float x );
559 long double roundl( long double x );
562 double trunc( double x );
563 float truncf( float x );
564 long double truncl( long double x );
566 double nearbyint( double x );
567 float nearbyintf( float x );
568 long double nearbyintl( long double x );
570 double nextafter( double x, double y );
571 float nextafterf( float x, float y );
572 long double nextafterl( long double x, long double y );
575 double nexttoward( double x, long double y );
576 float nexttowardf( float x, long double y );
577 long double nexttowardl( long double x, long double y );
580 double remainder( double x, double y );
581 float remainderf( float x, float y );
582 long double remainderl( long double x, long double y );
585 double remquo( double x, double y, int * pquo );
586 float remquof( float x, float y, int * pquo );
587 long double remquol( long double x, long double y, int * pquo );
590 double scalbn( double x, int ex );
591 float scalbnf( float x, int ex );
592 long double scalbnl( long double x, int ex );
595 double scalbln( double x, long ex );
596 float scalblnf( float x, long ex );
597 long double scalblnl( long double x, long ex );
600 double lgamma( double x );
601 float lgammaf( float x );
602 long double lgammal( long double x );
605 double tgamma( double x );
606 float tgammaf( float x );
607 long double tgammal( long double x );
610 double nan( const char *str );
611 float nanf( const char *str );
612 long double nanl( const char *str );