2 * D header file for C99.
4 * Copyright: Public Domain
5 * License: Public Domain
6 * Authors: Sean Kelly, Walter Bright
7 * Standards: ISO/IEC 9899:1999 (E)
11 private import stdc.config;
16 alias double double_t;
18 const double HUGE_VAL = double.infinity;
19 const double HUGE_VALF = float.infinity;
20 const double HUGE_VALL = real.infinity;
22 const float INFINITY = float.infinity;
23 const float NAN = float.nan;
25 const int FP_ILOGB0 = int.min;
26 const int FP_ILOGBNAN = int.min;
28 const int MATH_ERRNO = 1;
29 const int MATH_ERREXCEPT = 2;
30 const int math_errhandling = MATH_ERRNO | MATH_ERREXCEPT;
35 // these functions are all macros in C
38 //int fpclassify(real-floating x);
39 int fpclassify(float x);
40 int fpclassify(double x);
41 int fpclassify(real x);
43 //int isfinite(real-floating x);
44 int isfinite(float x);
45 int isfinite(double x);
48 //int isinf(real-floating x);
53 //int isnan(real-floating x);
58 //int isnormal(real-floating x);
59 int isnormal(float x);
60 int isnormal(double x);
63 //int signbit(real-floating x);
65 int signbit(double x);
68 //int isgreater(real-floating x, real-floating y);
69 int isgreater(float x, float y);
70 int isgreater(double x, double y);
71 int isgreater(real x, real y);
73 //int isgreaterequal(real-floating x, real-floating y);
74 int isgreaterequal(float x, float y);
75 int isgreaterequal(double x, double y);
76 int isgreaterequal(real x, real y);
78 //int isless(real-floating x, real-floating y);
79 int isless(float x, float y);
80 int isless(double x, double y);
81 int isless(real x, real y);
83 //int islessequal(real-floating x, real-floating y);
84 int islessequal(float x, float y);
85 int islessequal(double x, double y);
86 int islessequal(real x, real y);
88 //int islessgreater(real-floating x, real-floating y);
89 int islessgreater(float x, float y);
90 int islessgreater(double x, double y);
91 int islessgreater(real x, real y);
93 //int isunordered(real-floating x, real-floating y);
94 int isunordered(float x, float y);
95 int isunordered(double x, double y);
96 int isunordered(real x, real y);
99 version( DigitalMars ) version( Windows )
100 version = DigitalMarsWin32;
102 version( DigitalMarsWin32 )
124 uint __fpclassify_f(float x);
125 uint __fpclassify_d(double x);
126 uint __fpclassify_ld(real x);
130 //int fpclassify(real-floating x);
131 int fpclassify(float x) { return __fpclassify_f(x); }
132 int fpclassify(double x) { return __fpclassify_d(x); }
133 int fpclassify(real x)
135 return (real.sizeof == double.sizeof)
137 : __fpclassify_ld(x);
140 //int isfinite(real-floating x);
141 int isfinite(float x) { return fpclassify(x) >= FP_NORMAL; }
142 int isfinite(double x) { return fpclassify(x) >= FP_NORMAL; }
143 int isfinite(real x) { return fpclassify(x) >= FP_NORMAL; }
145 //int isinf(real-floating x);
146 int isinf(float x) { return fpclassify(x) == FP_INFINITE; }
147 int isinf(double x) { return fpclassify(x) == FP_INFINITE; }
148 int isinf(real x) { return fpclassify(x) == FP_INFINITE; }
150 //int isnan(real-floating x);
151 int isnan(float x) { return fpclassify(x) <= FP_NANQ; }
152 int isnan(double x) { return fpclassify(x) <= FP_NANQ; }
153 int isnan(real x) { return fpclassify(x) <= FP_NANQ; }
155 //int isnormal(real-floating x);
156 int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
157 int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
158 int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
160 //int signbit(real-floating x);
161 int signbit(float x) { return (cast(short*)&(x))[1] & 0x8000; }
162 int signbit(double x) { return (cast(short*)&(x))[3] & 0x8000; }
165 return (real.sizeof == double.sizeof)
166 ? (cast(short*)&(x))[3] & 0x8000
167 : (cast(short*)&(x))[4] & 0x8000;
171 else version( linux )
189 int __fpclassifyf(float x);
190 int __fpclassify(double x);
191 int __fpclassifyl(real x);
193 int __finitef(float x);
194 int __finite(double x);
195 int __finitel(real x);
197 int __isinff(float x);
198 int __isinf(double x);
199 int __isinfl(real x);
201 int __isnanf(float x);
202 int __isnan(double x);
203 int __isnanl(real x);
205 int __signbitf(float x);
206 int __signbit(double x);
207 int __signbitl(real x);
211 //int fpclassify(real-floating x);
212 int fpclassify(float x) { return __fpclassifyf(x); }
213 int fpclassify(double x) { return __fpclassify(x); }
214 int fpclassify(real x)
216 return (real.sizeof == double.sizeof)
221 //int isfinite(real-floating x);
222 int isfinite(float x) { return __finitef(x); }
223 int isfinite(double x) { return __finite(x); }
226 return (real.sizeof == double.sizeof)
231 //int isinf(real-floating x);
232 int isinf(float x) { return __isinff(x); }
233 int isinf(double x) { return __isinf(x); }
236 return (real.sizeof == double.sizeof)
241 //int isnan(real-floating x);
242 int isnan(float x) { return __isnanf(x); }
243 int isnan(double x) { return __isnan(x); }
246 return (real.sizeof == double.sizeof)
251 //int isnormal(real-floating x);
252 int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
253 int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
254 int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
256 //int signbit(real-floating x);
257 int signbit(float x) { return __signbitf(x); }
258 int signbit(double x) { return __signbit(x); }
261 return (real.sizeof == double.sizeof)
267 else version( darwin )
286 int __fpclassifyf(float x);
287 int __fpclassifyd(double x);
288 int __fpclassify(real x);
290 int __isfinitef(float x);
291 int __isfinited(double x);
292 int __isfinite(real x);
294 int __isinff(float x);
295 int __isinfd(double x);
298 int __isnanf(float x);
299 int __isnand(double x);
302 int __signbitf(float x);
303 int __signbitd(double x);
304 int __signbitl(real x);
308 //int fpclassify(real-floating x);
309 int fpclassify(float x) { return __fpclassifyf(x); }
310 int fpclassify(double x) { return __fpclassifyd(x); }
311 int fpclassify(real x)
313 return (real.sizeof == double.sizeof)
318 //int isfinite(real-floating x);
319 int isfinite(float x) { return __isfinitef(x); }
320 int isfinite(double x) { return __isfinited(x); }
323 return (real.sizeof == double.sizeof)
328 //int isinf(real-floating x);
329 int isinf(float x) { return __isinff(x); }
330 int isinf(double x) { return __isinfd(x); }
333 return (real.sizeof == double.sizeof)
338 //int isnan(real-floating x);
339 int isnan(float x) { return __isnanf(x); }
340 int isnan(double x) { return __isnand(x); }
343 return (real.sizeof == double.sizeof)
348 //int isnormal(real-floating x);
349 int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
350 int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
351 int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
353 //int signbit(real-floating x);
354 int signbit(float x) { return __signbitf(x); }
355 int signbit(double x) { return __signbitd(x); }
358 return (real.sizeof == double.sizeof)
364 else version( freebsd )
382 int __fpclassifyd(double);
383 int __fpclassifyf(float);
384 int __fpclassifyl(real);
385 int __isfinitef(float);
386 int __isfinite(double);
387 int __isfinitel(real);
391 int __isnormalf(float);
392 int __isnormal(double);
393 int __isnormall(real);
394 int __signbit(double);
395 int __signbitf(float);
396 int __signbitl(real);
400 //int fpclassify(real-floating x);
401 int fpclassify(float x) { return __fpclassifyf(x); }
402 int fpclassify(double x) { return __fpclassifyd(x); }
403 int fpclassify(real x) { return __fpclassifyl(x); }
405 //int isfinite(real-floating x);
406 int isfinite(float x) { return __isfinitef(x); }
407 int isfinite(double x) { return __isfinite(x); }
408 int isfinite(double x) { return __isfinitel(x); }
410 //int isinf(real-floating x);
411 int isinf(float x) { return __isinff(x); }
412 int isinf(double x) { return __isinfl(x); }
413 int isinf(real x) { return __isinfl(x); }
415 //int isnan(real-floating x);
416 int isnan(float x) { return __isnanl(x); }
417 int isnan(double x) { return __isnanl(x); }
418 int isnan(real x) { return __isnanl(x); }
420 //int isnormal(real-floating x);
421 int isnormal(float x) { return __isnormalf(x); }
422 int isnormal(double x) { return __isnormal(x); }
423 int isnormal(real x) { return __isnormall(x); }
425 //int signbit(real-floating x);
426 int signbit(float x) { return __signbitf(x); }
427 int signbit(double x) { return __signbit(x); }
428 int signbit(double x) { return __signbit(x); }
434 //int isgreater(real-floating x, real-floating y);
435 int isgreater(float x, float y) { return !(x !> y); }
436 int isgreater(double x, double y) { return !(x !> y); }
437 int isgreater(real x, real y) { return !(x !> y); }
439 //int isgreaterequal(real-floating x, real-floating y);
440 int isgreaterequal(float x, float y) { return !(x !>= y); }
441 int isgreaterequal(double x, double y) { return !(x !>= y); }
442 int isgreaterequal(real x, real y) { return !(x !>= y); }
444 //int isless(real-floating x, real-floating y);
445 int isless(float x, float y) { return !(x !< y); }
446 int isless(double x, double y) { return !(x !< y); }
447 int isless(real x, real y) { return !(x !< y); }
449 //int islessequal(real-floating x, real-floating y);
450 int islessequal(float x, float y) { return !(x !<= y); }
451 int islessequal(double x, double y) { return !(x !<= y); }
452 int islessequal(real x, real y) { return !(x !<= y); }
454 //int islessgreater(real-floating x, real-floating y);
455 int islessgreater(float x, float y) { return !(x !<> y); }
456 int islessgreater(double x, double y) { return !(x !<> y); }
457 int islessgreater(real x, real y) { return !(x !<> y); }
459 //int isunordered(real-floating x, real-floating y);
460 int isunordered(float x, float y) { return (x !<>= y); }
461 int isunordered(double x, double y) { return (x !<>= y); }
462 int isunordered(real x, real y) { return (x !<>= y); }
465 double acos(double x);
466 float acosf(float x);
469 double asin(double x);
470 float asinf(float x);
473 double atan(double x);
474 float atanf(float x);
477 double atan2(double y, double x);
478 float atan2f(float y, float x);
479 real atan2l(real y, real x);
481 double cos(double x);
485 double sin(double x);
489 double tan(double x);
493 double acosh(double x);
494 float acoshf(float x);
497 double asinh(double x);
498 float asinhf(float x);
501 double atanh(double x);
502 float atanhf(float x);
505 double cosh(double x);
506 float coshf(float x);
509 double sinh(double x);
510 float sinhf(float x);
513 double tanh(double x);
514 float tanhf(float x);
517 double exp(double x);
521 double exp2(double x);
522 float exp2f(float x);
525 double expm1(double x);
526 float expm1f(float x);
529 double frexp(double value, int* exp);
530 float frexpf(float value, int* exp);
531 real frexpl(real value, int* exp);
537 double ldexp(double x, int exp);
538 float ldexpf(float x, int exp);
539 real ldexpl(real x, int exp);
541 double log(double x);
545 double log10(double x);
546 float log10f(float x);
549 double log1p(double x);
550 float log1pf(float x);
553 double log2(double x);
554 float log2f(float x);
557 double logb(double x);
558 float logbf(float x);
561 double modf(double value, double* iptr);
562 float modff(float value, float* iptr);
563 real modfl(real value, real *iptr);
565 double scalbn(double x, int n);
566 float scalbnf(float x, int n);
567 real scalbnl(real x, int n);
569 double scalbln(double x, c_long n);
570 float scalblnf(float x, c_long n);
571 real scalblnl(real x, c_long n);
573 double cbrt(double x);
574 float cbrtf(float x);
577 double fabs(double x);
578 float fabsf(float x);
581 double hypot(double x, double y);
582 float hypotf(float x, float y);
583 real hypotl(real x, real y);
585 double pow(double x, double y);
586 float powf(float x, float y);
587 real powl(real x, real y);
589 double sqrt(double x);
590 float sqrtf(float x);
593 double erf(double x);
597 double erfc(double x);
598 float erfcf(float x);
601 double lgamma(double x);
602 float lgammaf(float x);
603 real lgammal(real x);
605 double tgamma(double x);
606 float tgammaf(float x);
607 real tgammal(real x);
609 double ceil(double x);
610 float ceilf(float x);
613 double floor(double x);
614 float floorf(float x);
617 double nearbyint(double x);
618 float nearbyintf(float x);
619 real nearbyintl(real x);
621 double rint(double x);
622 float rintf(float x);
625 c_long lrint(double x);
626 c_long lrintf(float x);
627 c_long lrintl(real x);
629 long llrint(double x);
630 long llrintf(float x);
631 long llrintl(real x);
633 double round(double x);
634 float roundf(float x);
637 c_long lround(double x);
638 c_long lroundf(float x);
639 c_long lroundl(real x);
641 long llround(double x);
642 long llroundf(float x);
643 long llroundl(real x);
645 double trunc(double x);
646 float truncf(float x);
649 double fmod(double x, double y);
650 float fmodf(float x, float y);
651 real fmodl(real x, real y);
653 double remainder(double x, double y);
654 float remainderf(float x, float y);
655 real remainderl(real x, real y);
657 double remquo(double x, double y, int* quo);
658 float remquof(float x, float y, int* quo);
659 real remquol(real x, real y, int* quo);
661 double copysign(double x, double y);
662 float copysignf(float x, float y);
663 real copysignl(real x, real y);
665 double nan(in char* tagp);
666 float nanf(in char* tagp);
667 real nanl(in char* tagp);
669 double nextafter(double x, double y);
670 float nextafterf(float x, float y);
671 real nextafterl(real x, real y);
673 double nexttoward(double x, real y);
674 float nexttowardf(float x, real y);
675 real nexttowardl(real x, real y);
677 double fdim(double x, double y);
678 float fdimf(float x, float y);
679 real fdiml(real x, real y);
681 double fmax(double x, double y);
682 float fmaxf(float x, float y);
683 real fmaxl(real x, real y);
685 double fmin(double x, double y);
686 float fminf(float x, float y);
687 real fminl(real x, real y);
689 double fma(double x, double y, double z);
690 float fmaf(float x, float y, float z);
691 real fmal(real x, real y, real z);