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 core.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(real 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(real 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 // NOTE: freebsd < 8-CURRENT doesn't appear to support *l, but we can
469 double acos(double x);
470 float acosf(float x);
471 real acosl(real x) { return acos(x); }
473 double asin(double x);
474 float asinf(float x);
475 real asinl(real x) { return asin(x); }
477 double atan(double x);
478 float atanf(float x);
479 real atanl(real x) { return atan(x); }
481 double atan2(double y, double x);
482 float atan2f(float y, float x);
483 real atan2l(real y, real x) { return atan2(y, x); }
485 double cos(double x);
487 real cosl(real x) { return cos(x); }
489 double sin(double x);
491 real sinl(real x) { return sin(x); }
493 double tan(double x);
495 real tanl(real x) { return tan(x); }
497 double acosh(double x);
498 float acoshf(float x);
499 real acoshl(real x) { return acosh(x); }
501 double asinh(double x);
502 float asinhf(float x);
503 real asinhl(real x) { return asinh(x); }
505 double atanh(double x);
506 float atanhf(float x);
507 real atanhl(real x) { return atanh(x); }
509 double cosh(double x);
510 float coshf(float x);
511 real coshl(real x) { return cosh(x); }
513 double sinh(double x);
514 float sinhf(float x);
515 real sinhl(real x) { return sinh(x); }
517 double tanh(double x);
518 float tanhf(float x);
519 real tanhl(real x) { return tanh(x); }
521 double exp(double x);
523 real expl(real x) { return exp(x); }
525 double exp2(double x);
526 float exp2f(float x);
527 real exp2l(real x) { return exp2(x); }
529 double expm1(double x);
530 float expm1f(float x);
531 real expm1l(real x) { return expm1(x); }
533 double frexp(double value, int* exp);
534 float frexpf(float value, int* exp);
535 real frexpl(real value, int* exp) { return frexp(value, exp); }
539 int ilogbl(real x) { return ilogb(x); }
541 double ldexp(double x, int exp);
542 float ldexpf(float x, int exp);
543 real ldexpl(real x, int exp) { return ldexp(x, exp); }
545 double log(double x);
547 real logl(real x) { return log(x); }
549 double log10(double x);
550 float log10f(float x);
551 real log10l(real x) { return log10(x); }
553 double log1p(double x);
554 float log1pf(float x);
555 real log1pl(real x) { return log1p(x); }
557 private const real ONE_LN2 = 1 / 0x1.62e42fefa39ef358p-1L;
558 double log2(double x) { return log(x) * ONE_LN2; }
559 float log2f(float x) { return logf(x) * ONE_LN2; }
560 real log2l(real x) { return logl(x) * ONE_LN2; }
562 double logb(double x);
563 float logbf(float x);
564 real logbl(real x) { return logb(x); }
566 double modf(double value, double* iptr);
567 float modff(float value, float* iptr);
568 //real modfl(real value, real *iptr); // nontrivial conversion
570 double scalbn(double x, int n);
571 float scalbnf(float x, int n);
572 real scalbnl(real x, int n) { return scalbn(x, n); }
574 double scalbln(double x, c_long n);
575 float scalblnf(float x, c_long n);
576 real scalblnl(real x, c_long n) { return scalbln(x, n); }
579 double cbrt(double x);
580 float cbrtf(float x);
581 real cbrtl(real x) { return cbrt(x); }
583 double fabs(double x);
584 float fabsf(float x);
585 real fabsl(real x) { return fabs(x); }
587 double hypot(double x, double y);
588 float hypotf(float x, float y);
589 real hypotl(real x, real y) { return hypot(x, y); }
591 double pow(double x, double y);
592 float powf(float x, float y);
593 real powl(real x, real y) { return pow(x, y); }
595 double sqrt(double x);
596 float sqrtf(float x);
597 real sqrtl(real x) { return sqrt(x); }
599 double erf(double x);
601 real erfl(real x) { return erf(x); }
603 double erfc(double x);
604 float erfcf(float x);
605 real erfcl(real x) { return erfc(x); }
607 double lgamma(double x);
608 float lgammaf(float x);
609 real lgammal(real x) { return lgamma(x); }
611 double tgamma(double x);
612 float tgammaf(float x);
613 real tgammal(real x) { return tgamma(x); }
615 double ceil(double x);
616 float ceilf(float x);
617 real ceill(real x) { return ceil(x); }
619 double floor(double x);
620 float floorf(float x);
621 real floorl(real x) { return floor(x); }
623 double nearbyint(double x);
624 float nearbyintf(float x);
625 real nearbyintl(real x) { return nearbyint(x); }
627 double rint(double x);
628 float rintf(float x);
629 real rintl(real x) { return rint(x); }
631 c_long lrint(double x);
632 c_long lrintf(float x);
633 c_long lrintl(real x) { return lrint(x); }
635 long llrint(double x);
636 long llrintf(float x);
637 long llrintl(real x) { return llrint(x); }
639 double round(double x);
640 float roundf(float x);
641 real roundl(real x) { return round(x); }
643 c_long lround(double x);
644 c_long lroundf(float x);
645 c_long lroundl(real x) { return lround(x); }
647 long llround(double x);
648 long llroundf(float x);
649 long llroundl(real x) { return llround(x); }
651 double trunc(double x);
652 float truncf(float x);
653 real truncl(real x) { return trunc(x); }
655 double fmod(double x, double y);
656 float fmodf(float x, float y);
657 real fmodl(real x, real y) { return fmod(x, y); }
659 double remainder(double x, double y);
660 float remainderf(float x, float y);
661 real remainderl(real x, real y) { return remainder(x, y); }
663 double remquo(double x, double y, int* quo);
664 float remquof(float x, float y, int* quo);
665 real remquol(real x, real y, int* quo) { return remquo(x, y, quo); }
667 double copysign(double x, double y);
668 float copysignf(float x, float y);
669 real copysignl(real x, real y) { return copysign(x, y); }
671 // double nan(char* tagp);
672 // float nanf(char* tagp);
673 // real nanl(char* tagp);
675 double nextafter(double x, double y);
676 float nextafterf(float x, float y);
677 real nextafterl(real x, real y) { return nextafter(x, y); }
679 double nexttoward(double x, real y);
680 float nexttowardf(float x, real y);
681 real nexttowardl(real x, real y) { return nexttoward(x, y); }
683 double fdim(double x, double y);
684 float fdimf(float x, float y);
685 real fdiml(real x, real y) { return fdim(x, y); }
687 double fmax(double x, double y);
688 float fmaxf(float x, float y);
689 real fmaxl(real x, real y) { return fmax(x, y); }
691 double fmin(double x, double y);
692 float fminf(float x, float y);
693 real fminl(real x, real y) { return fmin(x, y); }
695 double fma(double x, double y, double z);
696 float fmaf(float x, float y, float z);
697 real fmal(real x, real y, real z) { return fma(x, y, z); }
701 double acos(double x);
702 float acosf(float x);
705 double asin(double x);
706 float asinf(float x);
709 double atan(double x);
710 float atanf(float x);
713 double atan2(double y, double x);
714 float atan2f(float y, float x);
715 real atan2l(real y, real x);
717 double cos(double x);
721 double sin(double x);
725 double tan(double x);
729 double acosh(double x);
730 float acoshf(float x);
733 double asinh(double x);
734 float asinhf(float x);
737 double atanh(double x);
738 float atanhf(float x);
741 double cosh(double x);
742 float coshf(float x);
745 double sinh(double x);
746 float sinhf(float x);
749 double tanh(double x);
750 float tanhf(float x);
753 double exp(double x);
757 double exp2(double x);
758 float exp2f(float x);
761 double expm1(double x);
762 float expm1f(float x);
765 double frexp(double value, int* exp);
766 float frexpf(float value, int* exp);
767 real frexpl(real value, int* exp);
773 double ldexp(double x, int exp);
774 float ldexpf(float x, int exp);
775 real ldexpl(real x, int exp);
777 double log(double x);
781 double log10(double x);
782 float log10f(float x);
785 double log1p(double x);
786 float log1pf(float x);
789 double log2(double x);
790 float log2f(float x);
793 double logb(double x);
794 float logbf(float x);
797 double modf(double value, double* iptr);
798 float modff(float value, float* iptr);
799 real modfl(real value, real *iptr);
801 double scalbn(double x, int n);
802 float scalbnf(float x, int n);
803 real scalbnl(real x, int n);
805 double scalbln(double x, c_long n);
806 float scalblnf(float x, c_long n);
807 real scalblnl(real x, c_long n);
809 double cbrt(double x);
810 float cbrtf(float x);
813 double fabs(double x);
814 float fabsf(float x);
817 double hypot(double x, double y);
818 float hypotf(float x, float y);
819 real hypotl(real x, real y);
821 double pow(double x, double y);
822 float powf(float x, float y);
823 real powl(real x, real y);
825 double sqrt(double x);
826 float sqrtf(float x);
829 double erf(double x);
833 double erfc(double x);
834 float erfcf(float x);
837 double lgamma(double x);
838 float lgammaf(float x);
839 real lgammal(real x);
841 double tgamma(double x);
842 float tgammaf(float x);
843 real tgammal(real x);
845 double ceil(double x);
846 float ceilf(float x);
849 double floor(double x);
850 float floorf(float x);
853 double nearbyint(double x);
854 float nearbyintf(float x);
855 real nearbyintl(real x);
857 double rint(double x);
858 float rintf(float x);
861 c_long lrint(double x);
862 c_long lrintf(float x);
863 c_long lrintl(real x);
865 long llrint(double x);
866 long llrintf(float x);
867 long llrintl(real x);
869 double round(double x);
870 float roundf(float x);
873 c_long lround(double x);
874 c_long lroundf(float x);
875 c_long lroundl(real x);
877 long llround(double x);
878 long llroundf(float x);
879 long llroundl(real x);
881 double trunc(double x);
882 float truncf(float x);
885 double fmod(double x, double y);
886 float fmodf(float x, float y);
887 real fmodl(real x, real y);
889 double remainder(double x, double y);
890 float remainderf(float x, float y);
891 real remainderl(real x, real y);
893 double remquo(double x, double y, int* quo);
894 float remquof(float x, float y, int* quo);
895 real remquol(real x, real y, int* quo);
897 double copysign(double x, double y);
898 float copysignf(float x, float y);
899 real copysignl(real x, real y);
901 double nan(char* tagp);
902 float nanf(char* tagp);
903 real nanl(char* tagp);
905 double nextafter(double x, double y);
906 float nextafterf(float x, float y);
907 real nextafterl(real x, real y);
909 double nexttoward(double x, real y);
910 float nexttowardf(float x, real y);
911 real nexttowardl(real x, real y);
913 double fdim(double x, double y);
914 float fdimf(float x, float y);
915 real fdiml(real x, real y);
917 double fmax(double x, double y);
918 float fmaxf(float x, float y);
919 real fmaxl(real x, real y);
921 double fmin(double x, double y);
922 float fminf(float x, float y);
923 real fminl(real x, real y);
925 double fma(double x, double y, double z);
926 float fmaf(float x, float y, float z);
927 real fmal(real x, real y, real z);