1*84d9c625SLionel Sambuc /* $NetBSD: math.h,v 1.63 2013/09/16 15:54:42 martin Exp $ */ 29865aeaaSBen Gras 32fe8fb19SBen Gras /* 42fe8fb19SBen Gras * ==================================================== 52fe8fb19SBen Gras * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 62fe8fb19SBen Gras * 72fe8fb19SBen Gras * Developed at SunPro, a Sun Microsystems, Inc. business. 82fe8fb19SBen Gras * Permission to use, copy, modify, and distribute this 92fe8fb19SBen Gras * software is freely granted, provided that this notice 102fe8fb19SBen Gras * is preserved. 112fe8fb19SBen Gras * ==================================================== 12a34d34bcSKees van Reeuwijk */ 132fe8fb19SBen Gras 142fe8fb19SBen Gras /* 152fe8fb19SBen Gras * @(#)fdlibm.h 5.1 93/09/24 162fe8fb19SBen Gras */ 172fe8fb19SBen Gras 182fe8fb19SBen Gras #ifndef _MATH_H_ 192fe8fb19SBen Gras #define _MATH_H_ 202fe8fb19SBen Gras 212fe8fb19SBen Gras #include <sys/cdefs.h> 222fe8fb19SBen Gras #include <sys/featuretest.h> 232fe8fb19SBen Gras 242fe8fb19SBen Gras union __float_u { 252fe8fb19SBen Gras unsigned char __dummy[sizeof(float)]; 262fe8fb19SBen Gras float __val; 272fe8fb19SBen Gras }; 282fe8fb19SBen Gras 292fe8fb19SBen Gras union __double_u { 302fe8fb19SBen Gras unsigned char __dummy[sizeof(double)]; 312fe8fb19SBen Gras double __val; 322fe8fb19SBen Gras }; 332fe8fb19SBen Gras 342fe8fb19SBen Gras union __long_double_u { 352fe8fb19SBen Gras unsigned char __dummy[sizeof(long double)]; 362fe8fb19SBen Gras long double __val; 372fe8fb19SBen Gras }; 382fe8fb19SBen Gras 392fe8fb19SBen Gras #include <machine/math.h> /* may use __float_u, __double_u, 402fe8fb19SBen Gras or __long_double_u */ 41*84d9c625SLionel Sambuc #include <limits.h> /* for INT_{MIN,MAX} */ 42*84d9c625SLionel Sambuc 43*84d9c625SLionel Sambuc #if ((_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE)) 44*84d9c625SLionel Sambuc # if defined(__FLT_EVAL_METHOD__) && (__FLT_EVAL_METHOD__ - 0) == 0 45*84d9c625SLionel Sambuc typedef double double_t; 46*84d9c625SLionel Sambuc typedef float float_t; 47*84d9c625SLionel Sambuc # elif (__FLT_EVAL_METHOD__ - 0) == 1 48*84d9c625SLionel Sambuc typedef double double_t; 49*84d9c625SLionel Sambuc typedef double float_t; 50*84d9c625SLionel Sambuc # elif (__FLT_EVAL_METHOD__ - 0) == 2 51*84d9c625SLionel Sambuc typedef long double double_t; 52*84d9c625SLionel Sambuc typedef long double float_t; 53*84d9c625SLionel Sambuc # endif 54*84d9c625SLionel Sambuc #endif 552fe8fb19SBen Gras 562fe8fb19SBen Gras #ifdef __HAVE_LONG_DOUBLE 572fe8fb19SBen Gras #define __fpmacro_unary_floating(__name, __arg0) \ 582fe8fb19SBen Gras /* LINTED */ \ 592fe8fb19SBen Gras ((sizeof (__arg0) == sizeof (float)) \ 602fe8fb19SBen Gras ? __ ## __name ## f (__arg0) \ 612fe8fb19SBen Gras : (sizeof (__arg0) == sizeof (double)) \ 622fe8fb19SBen Gras ? __ ## __name ## d (__arg0) \ 632fe8fb19SBen Gras : __ ## __name ## l (__arg0)) 642fe8fb19SBen Gras #else 652fe8fb19SBen Gras #define __fpmacro_unary_floating(__name, __arg0) \ 662fe8fb19SBen Gras /* LINTED */ \ 672fe8fb19SBen Gras ((sizeof (__arg0) == sizeof (float)) \ 682fe8fb19SBen Gras ? __ ## __name ## f (__arg0) \ 692fe8fb19SBen Gras : __ ## __name ## d (__arg0)) 702fe8fb19SBen Gras #endif /* __HAVE_LONG_DOUBLE */ 712fe8fb19SBen Gras 722fe8fb19SBen Gras /* 732fe8fb19SBen Gras * ANSI/POSIX 742fe8fb19SBen Gras */ 752fe8fb19SBen Gras /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */ 762fe8fb19SBen Gras #if __GNUC_PREREQ__(3, 3) 772fe8fb19SBen Gras #define HUGE_VAL __builtin_huge_val() 782fe8fb19SBen Gras #else 792fe8fb19SBen Gras extern const union __double_u __infinity; 802fe8fb19SBen Gras #define HUGE_VAL __infinity.__val 81b6f25271SBen Gras #endif 8211cbb6faSPhilip Homburg 832fe8fb19SBen Gras /* 842fe8fb19SBen Gras * ISO C99 852fe8fb19SBen Gras */ 862fe8fb19SBen Gras #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ 872fe8fb19SBen Gras !defined(_XOPEN_SOURCE) || \ 882fe8fb19SBen Gras ((__STDC_VERSION__ - 0) >= 199901L) || \ 892fe8fb19SBen Gras ((_POSIX_C_SOURCE - 0) >= 200112L) || \ 902fe8fb19SBen Gras ((_XOPEN_SOURCE - 0) >= 600) || \ 912fe8fb19SBen Gras defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) 922fe8fb19SBen Gras /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */ 932fe8fb19SBen Gras #if __GNUC_PREREQ__(3, 3) 942fe8fb19SBen Gras #define HUGE_VALF __builtin_huge_valf() 952fe8fb19SBen Gras #define HUGE_VALL __builtin_huge_vall() 962fe8fb19SBen Gras #else 972fe8fb19SBen Gras extern const union __float_u __infinityf; 982fe8fb19SBen Gras #define HUGE_VALF __infinityf.__val 992fe8fb19SBen Gras 1002fe8fb19SBen Gras extern const union __long_double_u __infinityl; 1012fe8fb19SBen Gras #define HUGE_VALL __infinityl.__val 1022fe8fb19SBen Gras #endif 1032fe8fb19SBen Gras 1042fe8fb19SBen Gras /* 7.12#4 INFINITY */ 105f14fb602SLionel Sambuc #if defined(__INFINITY) 1062fe8fb19SBen Gras #define INFINITY __INFINITY /* float constant which overflows */ 107f14fb602SLionel Sambuc #elif __GNUC_PREREQ__(3, 3) 108f14fb602SLionel Sambuc #define INFINITY __builtin_inff() 1092fe8fb19SBen Gras #else 1102fe8fb19SBen Gras #define INFINITY HUGE_VALF /* positive infinity */ 1112fe8fb19SBen Gras #endif /* __INFINITY */ 1122fe8fb19SBen Gras 1132fe8fb19SBen Gras /* 7.12#5 NAN: a quiet NaN, if supported */ 1142fe8fb19SBen Gras #ifdef __HAVE_NANF 1152fe8fb19SBen Gras #if __GNUC_PREREQ__(3,3) 1162fe8fb19SBen Gras #define NAN __builtin_nanf("") 1172fe8fb19SBen Gras #else 1182fe8fb19SBen Gras extern const union __float_u __nanf; 1192fe8fb19SBen Gras #define NAN __nanf.__val 1202fe8fb19SBen Gras #endif 1212fe8fb19SBen Gras #endif /* __HAVE_NANF */ 1222fe8fb19SBen Gras 1232fe8fb19SBen Gras /* 7.12#6 number classification macros */ 1242fe8fb19SBen Gras #define FP_INFINITE 0x00 1252fe8fb19SBen Gras #define FP_NAN 0x01 1262fe8fb19SBen Gras #define FP_NORMAL 0x02 1272fe8fb19SBen Gras #define FP_SUBNORMAL 0x03 1282fe8fb19SBen Gras #define FP_ZERO 0x04 1292fe8fb19SBen Gras /* NetBSD extensions */ 1302fe8fb19SBen Gras #define _FP_LOMD 0x80 /* range for machine-specific classes */ 1312fe8fb19SBen Gras #define _FP_HIMD 0xff 1322fe8fb19SBen Gras 133*84d9c625SLionel Sambuc #define FP_ILOGB0 INT_MIN 134*84d9c625SLionel Sambuc #define FP_ILOGBNAN INT_MAX 135*84d9c625SLionel Sambuc 1362fe8fb19SBen Gras #endif /* !_ANSI_SOURCE && ... */ 1372fe8fb19SBen Gras 1382fe8fb19SBen Gras /* 1392fe8fb19SBen Gras * XOPEN/SVID 1402fe8fb19SBen Gras */ 1412fe8fb19SBen Gras #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 1422fe8fb19SBen Gras #define M_E 2.7182818284590452354 /* e */ 1432fe8fb19SBen Gras #define M_LOG2E 1.4426950408889634074 /* log 2e */ 1442fe8fb19SBen Gras #define M_LOG10E 0.43429448190325182765 /* log 10e */ 1452fe8fb19SBen Gras #define M_LN2 0.69314718055994530942 /* log e2 */ 1462fe8fb19SBen Gras #define M_LN10 2.30258509299404568402 /* log e10 */ 1472fe8fb19SBen Gras #define M_PI 3.14159265358979323846 /* pi */ 1482fe8fb19SBen Gras #define M_PI_2 1.57079632679489661923 /* pi/2 */ 1492fe8fb19SBen Gras #define M_PI_4 0.78539816339744830962 /* pi/4 */ 1502fe8fb19SBen Gras #define M_1_PI 0.31830988618379067154 /* 1/pi */ 1512fe8fb19SBen Gras #define M_2_PI 0.63661977236758134308 /* 2/pi */ 1522fe8fb19SBen Gras #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ 1532fe8fb19SBen Gras #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ 1542fe8fb19SBen Gras #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ 1552fe8fb19SBen Gras 1562fe8fb19SBen Gras #define MAXFLOAT ((float)3.40282346638528860e+38) 1572fe8fb19SBen Gras extern int signgam; 1582fe8fb19SBen Gras #endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ 1592fe8fb19SBen Gras 1602fe8fb19SBen Gras #if defined(_NETBSD_SOURCE) 1612fe8fb19SBen Gras enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix}; 1622fe8fb19SBen Gras 1632fe8fb19SBen Gras #define _LIB_VERSION_TYPE enum fdversion 1642fe8fb19SBen Gras #define _LIB_VERSION _fdlib_version 1652fe8fb19SBen Gras 1662fe8fb19SBen Gras /* if global variable _LIB_VERSION is not desirable, one may 1672fe8fb19SBen Gras * change the following to be a constant by: 1682fe8fb19SBen Gras * #define _LIB_VERSION_TYPE const enum version 1692fe8fb19SBen Gras * In that case, after one initializes the value _LIB_VERSION (see 1702fe8fb19SBen Gras * s_lib_version.c) during compile time, it cannot be modified 1712fe8fb19SBen Gras * in the middle of a program 1722fe8fb19SBen Gras */ 1732fe8fb19SBen Gras extern _LIB_VERSION_TYPE _LIB_VERSION; 1742fe8fb19SBen Gras 1752fe8fb19SBen Gras #define _IEEE_ fdlibm_ieee 1762fe8fb19SBen Gras #define _SVID_ fdlibm_svid 1772fe8fb19SBen Gras #define _XOPEN_ fdlibm_xopen 1782fe8fb19SBen Gras #define _POSIX_ fdlibm_posix 1792fe8fb19SBen Gras 1802fe8fb19SBen Gras #ifndef __cplusplus 1812fe8fb19SBen Gras struct exception { 1822fe8fb19SBen Gras int type; 1832fe8fb19SBen Gras const char *name; 1842fe8fb19SBen Gras double arg1; 1852fe8fb19SBen Gras double arg2; 1862fe8fb19SBen Gras double retval; 1872fe8fb19SBen Gras }; 1882fe8fb19SBen Gras #endif 1892fe8fb19SBen Gras 1902fe8fb19SBen Gras #define HUGE MAXFLOAT 1912fe8fb19SBen Gras 1922fe8fb19SBen Gras /* 1932fe8fb19SBen Gras * set X_TLOSS = pi*2**52, which is possibly defined in <values.h> 1942fe8fb19SBen Gras * (one may replace the following line by "#include <values.h>") 1952fe8fb19SBen Gras */ 1962fe8fb19SBen Gras 1972fe8fb19SBen Gras #define X_TLOSS 1.41484755040568800000e+16 1982fe8fb19SBen Gras 1992fe8fb19SBen Gras #define DOMAIN 1 2002fe8fb19SBen Gras #define SING 2 2012fe8fb19SBen Gras #define OVERFLOW 3 2022fe8fb19SBen Gras #define UNDERFLOW 4 2032fe8fb19SBen Gras #define TLOSS 5 2042fe8fb19SBen Gras #define PLOSS 6 2052fe8fb19SBen Gras 2062fe8fb19SBen Gras #endif /* _NETBSD_SOURCE */ 2072fe8fb19SBen Gras 2082fe8fb19SBen Gras __BEGIN_DECLS 2092fe8fb19SBen Gras /* 2102fe8fb19SBen Gras * ANSI/POSIX 2112fe8fb19SBen Gras */ 2122fe8fb19SBen Gras double acos(double); 2132fe8fb19SBen Gras double asin(double); 2142fe8fb19SBen Gras double atan(double); 2152fe8fb19SBen Gras double atan2(double, double); 2162fe8fb19SBen Gras double cos(double); 2172fe8fb19SBen Gras double sin(double); 2182fe8fb19SBen Gras double tan(double); 2192fe8fb19SBen Gras 2202fe8fb19SBen Gras double cosh(double); 2212fe8fb19SBen Gras double sinh(double); 2222fe8fb19SBen Gras double tanh(double); 2232fe8fb19SBen Gras 2242fe8fb19SBen Gras double exp(double); 2252fe8fb19SBen Gras double exp2(double); 2262fe8fb19SBen Gras double frexp(double, int *); 2272fe8fb19SBen Gras double ldexp(double, int); 2282fe8fb19SBen Gras double log(double); 2292fe8fb19SBen Gras double log2(double); 2302fe8fb19SBen Gras double log10(double); 2312fe8fb19SBen Gras double modf(double, double *); 2322fe8fb19SBen Gras 2332fe8fb19SBen Gras double pow(double, double); 2342fe8fb19SBen Gras double sqrt(double); 2352fe8fb19SBen Gras 2362fe8fb19SBen Gras double ceil(double); 2372fe8fb19SBen Gras double fabs(double); 2382fe8fb19SBen Gras double floor(double); 2392fe8fb19SBen Gras double fmod(double, double); 2402fe8fb19SBen Gras 2412fe8fb19SBen Gras #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) 2422fe8fb19SBen Gras double erf(double); 2432fe8fb19SBen Gras double erfc(double); 2442fe8fb19SBen Gras double gamma(double); 2452fe8fb19SBen Gras double hypot(double, double); 2462fe8fb19SBen Gras int finite(double); 2472fe8fb19SBen Gras double j0(double); 2482fe8fb19SBen Gras double j1(double); 2492fe8fb19SBen Gras double jn(int, double); 2502fe8fb19SBen Gras double lgamma(double); 2512fe8fb19SBen Gras double y0(double); 2522fe8fb19SBen Gras double y1(double); 2532fe8fb19SBen Gras double yn(int, double); 2542fe8fb19SBen Gras 2552fe8fb19SBen Gras #if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) 2562fe8fb19SBen Gras double acosh(double); 2572fe8fb19SBen Gras double asinh(double); 2582fe8fb19SBen Gras double atanh(double); 2592fe8fb19SBen Gras double cbrt(double); 2602fe8fb19SBen Gras double expm1(double); 2612fe8fb19SBen Gras int ilogb(double); 2622fe8fb19SBen Gras double log1p(double); 2632fe8fb19SBen Gras double logb(double); 2642fe8fb19SBen Gras double nextafter(double, double); 2652fe8fb19SBen Gras double remainder(double, double); 2662fe8fb19SBen Gras double rint(double); 2672fe8fb19SBen Gras double scalb(double, double); 2682fe8fb19SBen Gras #endif /* (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)*/ 2692fe8fb19SBen Gras #endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */ 2702fe8fb19SBen Gras 2712fe8fb19SBen Gras /* 2722fe8fb19SBen Gras * ISO C99 2732fe8fb19SBen Gras */ 2742fe8fb19SBen Gras #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \ 2752fe8fb19SBen Gras !defined(_XOPEN_SOURCE) || \ 2762fe8fb19SBen Gras ((__STDC_VERSION__ - 0) >= 199901L) || \ 2772fe8fb19SBen Gras ((_POSIX_C_SOURCE - 0) >= 200112L) || \ 2782fe8fb19SBen Gras ((_XOPEN_SOURCE - 0) >= 600) || \ 2792fe8fb19SBen Gras defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) 2802fe8fb19SBen Gras /* 7.12.3.1 int fpclassify(real-floating x) */ 2812fe8fb19SBen Gras #define fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x) 2822fe8fb19SBen Gras 2832fe8fb19SBen Gras /* 7.12.3.2 int isfinite(real-floating x) */ 2842fe8fb19SBen Gras #define isfinite(__x) __fpmacro_unary_floating(isfinite, __x) 2852fe8fb19SBen Gras 2862fe8fb19SBen Gras /* 7.12.3.5 int isnormal(real-floating x) */ 2872fe8fb19SBen Gras #define isnormal(__x) (fpclassify(__x) == FP_NORMAL) 2882fe8fb19SBen Gras 2892fe8fb19SBen Gras /* 7.12.3.6 int signbit(real-floating x) */ 2902fe8fb19SBen Gras #define signbit(__x) __fpmacro_unary_floating(signbit, __x) 2912fe8fb19SBen Gras 2922fe8fb19SBen Gras /* 7.12.4 trigonometric */ 2932fe8fb19SBen Gras 2942fe8fb19SBen Gras float acosf(float); 2952fe8fb19SBen Gras float asinf(float); 2962fe8fb19SBen Gras float atanf(float); 2972fe8fb19SBen Gras float atan2f(float, float); 2982fe8fb19SBen Gras float cosf(float); 2992fe8fb19SBen Gras float sinf(float); 3002fe8fb19SBen Gras float tanf(float); 3012fe8fb19SBen Gras 302*84d9c625SLionel Sambuc long double acosl(long double); 303*84d9c625SLionel Sambuc long double asinl(long double); 304*84d9c625SLionel Sambuc long double atanl(long double); 305*84d9c625SLionel Sambuc long double atan2l(long double, long double); 306*84d9c625SLionel Sambuc long double cosl(long double); 307*84d9c625SLionel Sambuc long double sinl(long double); 308*84d9c625SLionel Sambuc long double tanl(long double); 309*84d9c625SLionel Sambuc 3102fe8fb19SBen Gras /* 7.12.5 hyperbolic */ 3112fe8fb19SBen Gras 3122fe8fb19SBen Gras float acoshf(float); 3132fe8fb19SBen Gras float asinhf(float); 3142fe8fb19SBen Gras float atanhf(float); 3152fe8fb19SBen Gras float coshf(float); 3162fe8fb19SBen Gras float sinhf(float); 3172fe8fb19SBen Gras float tanhf(float); 318*84d9c625SLionel Sambuc long double acoshl(long double); 319*84d9c625SLionel Sambuc long double asinhl(long double); 320*84d9c625SLionel Sambuc long double atanhl(long double); 321*84d9c625SLionel Sambuc long double coshl(long double); 322*84d9c625SLionel Sambuc long double sinhl(long double); 323*84d9c625SLionel Sambuc long double tanhl(long double); 3242fe8fb19SBen Gras 3252fe8fb19SBen Gras /* 7.12.6 exp / log */ 3262fe8fb19SBen Gras 3272fe8fb19SBen Gras float expf(float); 3282fe8fb19SBen Gras float exp2f(float); 3292fe8fb19SBen Gras float expm1f(float); 3302fe8fb19SBen Gras float frexpf(float, int *); 3312fe8fb19SBen Gras int ilogbf(float); 3322fe8fb19SBen Gras float ldexpf(float, int); 3332fe8fb19SBen Gras float logf(float); 3342fe8fb19SBen Gras float log2f(float); 3352fe8fb19SBen Gras float log10f(float); 3362fe8fb19SBen Gras float log1pf(float); 3372fe8fb19SBen Gras float logbf(float); 3382fe8fb19SBen Gras float modff(float, float *); 3392fe8fb19SBen Gras float scalbnf(float, int); 340*84d9c625SLionel Sambuc float scalblnf(float, long); 341*84d9c625SLionel Sambuc 342*84d9c625SLionel Sambuc long double expl(long double); 343*84d9c625SLionel Sambuc long double exp2l(long double); 344*84d9c625SLionel Sambuc long double expm1l(long double); 345*84d9c625SLionel Sambuc long double frexpl(long double, int *); 346*84d9c625SLionel Sambuc int ilogbl(long double); 347*84d9c625SLionel Sambuc long double ldexpl(long double, int); 348*84d9c625SLionel Sambuc long double logl(long double); 349*84d9c625SLionel Sambuc long double log2l(long double); 350*84d9c625SLionel Sambuc long double log10l(long double); 351*84d9c625SLionel Sambuc long double log1pl(long double); 352*84d9c625SLionel Sambuc long double logbl(long double); 353*84d9c625SLionel Sambuc long double modfl(long double, long double *); 354*84d9c625SLionel Sambuc long double scalbnl(long double, int); 355*84d9c625SLionel Sambuc long double scalblnl(long double, long); 356*84d9c625SLionel Sambuc 3572fe8fb19SBen Gras 3582fe8fb19SBen Gras /* 7.12.7 power / absolute */ 3592fe8fb19SBen Gras 3602fe8fb19SBen Gras float cbrtf(float); 3612fe8fb19SBen Gras float fabsf(float); 3622fe8fb19SBen Gras float hypotf(float, float); 3632fe8fb19SBen Gras float powf(float, float); 3642fe8fb19SBen Gras float sqrtf(float); 365*84d9c625SLionel Sambuc long double cbrtl(long double); 366*84d9c625SLionel Sambuc long double fabsl(long double); 367*84d9c625SLionel Sambuc long double hypotl(long double, long double); 368*84d9c625SLionel Sambuc long double powl(long double, long double); 369*84d9c625SLionel Sambuc long double sqrtl(long double); 3702fe8fb19SBen Gras 3712fe8fb19SBen Gras /* 7.12.8 error / gamma */ 3722fe8fb19SBen Gras 373*84d9c625SLionel Sambuc double tgamma(double); 3742fe8fb19SBen Gras float erff(float); 3752fe8fb19SBen Gras float erfcf(float); 3762fe8fb19SBen Gras float lgammaf(float); 377f14fb602SLionel Sambuc float tgammaf(float); 378*84d9c625SLionel Sambuc long double erfl(long double); 379*84d9c625SLionel Sambuc long double erfcl(long double); 380*84d9c625SLionel Sambuc long double lgammal(long double); 381*84d9c625SLionel Sambuc long double tgammal(long double); 3822fe8fb19SBen Gras 3832fe8fb19SBen Gras /* 7.12.9 nearest integer */ 3842fe8fb19SBen Gras 3852fe8fb19SBen Gras /* LONGLONG */ 3862fe8fb19SBen Gras long long int llrint(double); 3872fe8fb19SBen Gras long int lround(double); 3882fe8fb19SBen Gras /* LONGLONG */ 3892fe8fb19SBen Gras long long int llround(double); 390*84d9c625SLionel Sambuc long int lrint(double); 391*84d9c625SLionel Sambuc double round(double); 392*84d9c625SLionel Sambuc double trunc(double); 393*84d9c625SLionel Sambuc 394*84d9c625SLionel Sambuc float ceilf(float); 395*84d9c625SLionel Sambuc float floorf(float); 396*84d9c625SLionel Sambuc /* LONGLONG */ 397*84d9c625SLionel Sambuc long long int llrintf(float); 398*84d9c625SLionel Sambuc long int lroundf(float); 3992fe8fb19SBen Gras /* LONGLONG */ 4002fe8fb19SBen Gras long long int llroundf(float); 401*84d9c625SLionel Sambuc long int lrintf(float); 402*84d9c625SLionel Sambuc float rintf(float); 403*84d9c625SLionel Sambuc float roundf(float); 404*84d9c625SLionel Sambuc float truncf(float); 405*84d9c625SLionel Sambuc long double ceill(long double); 406*84d9c625SLionel Sambuc long double floorl(long double); 407*84d9c625SLionel Sambuc /* LONGLONG */ 408*84d9c625SLionel Sambuc long long int llrintl(long double); 409*84d9c625SLionel Sambuc long int lroundl(long double); 410*84d9c625SLionel Sambuc /* LONGLONG */ 411*84d9c625SLionel Sambuc long long int llroundl(long double); 412*84d9c625SLionel Sambuc long int lrintl(long double); 413*84d9c625SLionel Sambuc long double rintl(long double); 414*84d9c625SLionel Sambuc long double roundl(long double); 415*84d9c625SLionel Sambuc long double truncl(long double); 4162fe8fb19SBen Gras 4172fe8fb19SBen Gras /* 7.12.10 remainder */ 4182fe8fb19SBen Gras 4192fe8fb19SBen Gras float fmodf(float, float); 4202fe8fb19SBen Gras float remainderf(float, float); 421*84d9c625SLionel Sambuc long double fmodl(long double, long double); 422*84d9c625SLionel Sambuc long double remainderl(long double, long double); 4232fe8fb19SBen Gras 424f14fb602SLionel Sambuc /* 7.12.10.3 The remquo functions */ 425f14fb602SLionel Sambuc double remquo(double, double, int *); 426f14fb602SLionel Sambuc float remquof(float, float, int *); 427*84d9c625SLionel Sambuc long double remquol(long double, long double, int *); 428f14fb602SLionel Sambuc 4292fe8fb19SBen Gras /* 7.12.11 manipulation */ 4302fe8fb19SBen Gras 4312fe8fb19SBen Gras double nan(const char *); 432*84d9c625SLionel Sambuc double nearbyint(double); 4332fe8fb19SBen Gras double nexttoward(double, long double); 434*84d9c625SLionel Sambuc float copysignf(float, float); 435*84d9c625SLionel Sambuc float nanf(const char *); 436*84d9c625SLionel Sambuc float nearbyintf(float); 437*84d9c625SLionel Sambuc float nextafterf(float, float); 438*84d9c625SLionel Sambuc float nexttowardf(float, long double); 439*84d9c625SLionel Sambuc long double copysignl(long double, long double); 440*84d9c625SLionel Sambuc long double nanl(const char *); 441*84d9c625SLionel Sambuc long double nearbyintl(long double); 442*84d9c625SLionel Sambuc long double nextafterl(long double, long double); 443*84d9c625SLionel Sambuc long double nexttowardl(long double, long double); 4442fe8fb19SBen Gras 4452fe8fb19SBen Gras /* 7.12.14 comparison */ 4462fe8fb19SBen Gras 4472fe8fb19SBen Gras #define isunordered(x, y) (isnan(x) || isnan(y)) 4482fe8fb19SBen Gras #define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y)) 4492fe8fb19SBen Gras #define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y)) 4502fe8fb19SBen Gras #define isless(x, y) (!isunordered((x), (y)) && (x) < (y)) 4512fe8fb19SBen Gras #define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y)) 4522fe8fb19SBen Gras #define islessgreater(x, y) (!isunordered((x), (y)) && \ 4532fe8fb19SBen Gras ((x) > (y) || (y) > (x))) 4542fe8fb19SBen Gras double fdim(double, double); 455*84d9c625SLionel Sambuc double fma(double, double, double); 4562fe8fb19SBen Gras double fmax(double, double); 4572fe8fb19SBen Gras double fmin(double, double); 4582fe8fb19SBen Gras float fdimf(float, float); 459*84d9c625SLionel Sambuc float fmaf(float, float, float); 4602fe8fb19SBen Gras float fmaxf(float, float); 4612fe8fb19SBen Gras float fminf(float, float); 4622fe8fb19SBen Gras long double fdiml(long double, long double); 463*84d9c625SLionel Sambuc long double fmal(long double, long double, long double); 4642fe8fb19SBen Gras long double fmaxl(long double, long double); 4652fe8fb19SBen Gras long double fminl(long double, long double); 4662fe8fb19SBen Gras 4672fe8fb19SBen Gras #endif /* !_ANSI_SOURCE && ... */ 4682fe8fb19SBen Gras 4692fe8fb19SBen Gras #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) || \ 4702fe8fb19SBen Gras !defined(_XOPEN_SOURCE) || \ 4712fe8fb19SBen Gras ((__STDC_VERSION__ - 0) >= 199901L) || \ 4722fe8fb19SBen Gras ((_POSIX_C_SOURCE - 0) >= 200112L) || \ 4732fe8fb19SBen Gras defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) 4742fe8fb19SBen Gras /* 7.12.3.3 int isinf(real-floating x) */ 475*84d9c625SLionel Sambuc #if defined(__isinf) || defined(__HAVE_INLINE___ISINF) 4762fe8fb19SBen Gras #define isinf(__x) __isinf(__x) 4772fe8fb19SBen Gras #else 4782fe8fb19SBen Gras #define isinf(__x) __fpmacro_unary_floating(isinf, __x) 4792fe8fb19SBen Gras #endif 4802fe8fb19SBen Gras 4812fe8fb19SBen Gras /* 7.12.3.4 int isnan(real-floating x) */ 482*84d9c625SLionel Sambuc #if defined(__isnan) || defined(__HAVE_INLINE___ISNAN) 4832fe8fb19SBen Gras #define isnan(__x) __isnan(__x) 4842fe8fb19SBen Gras #else 4852fe8fb19SBen Gras #define isnan(__x) __fpmacro_unary_floating(isnan, __x) 4862fe8fb19SBen Gras #endif 4872fe8fb19SBen Gras #endif /* !_ANSI_SOURCE && ... */ 4882fe8fb19SBen Gras 4892fe8fb19SBen Gras #if defined(_NETBSD_SOURCE) 4902fe8fb19SBen Gras #ifndef __cplusplus 4912fe8fb19SBen Gras int matherr(struct exception *); 4922fe8fb19SBen Gras #endif 4932fe8fb19SBen Gras 4942fe8fb19SBen Gras /* 4952fe8fb19SBen Gras * IEEE Test Vector 4962fe8fb19SBen Gras */ 4972fe8fb19SBen Gras double significand(double); 4982fe8fb19SBen Gras 4992fe8fb19SBen Gras /* 5002fe8fb19SBen Gras * Functions callable from C, intended to support IEEE arithmetic. 5012fe8fb19SBen Gras */ 5022fe8fb19SBen Gras double copysign(double, double); 5032fe8fb19SBen Gras double scalbn(double, int); 504*84d9c625SLionel Sambuc double scalbln(double, long); 5052fe8fb19SBen Gras 5062fe8fb19SBen Gras /* 5072fe8fb19SBen Gras * BSD math library entry points 5082fe8fb19SBen Gras */ 5092fe8fb19SBen Gras double drem(double, double); 5102fe8fb19SBen Gras 5112fe8fb19SBen Gras #endif /* _NETBSD_SOURCE */ 5122fe8fb19SBen Gras 5132fe8fb19SBen Gras #if defined(_NETBSD_SOURCE) || defined(_REENTRANT) 5142fe8fb19SBen Gras /* 5152fe8fb19SBen Gras * Reentrant version of gamma & lgamma; passes signgam back by reference 5162fe8fb19SBen Gras * as the second argument; user must allocate space for signgam. 5172fe8fb19SBen Gras */ 5182fe8fb19SBen Gras double gamma_r(double, int *); 5192fe8fb19SBen Gras double lgamma_r(double, int *); 5202fe8fb19SBen Gras #endif /* _NETBSD_SOURCE || _REENTRANT */ 5212fe8fb19SBen Gras 5222fe8fb19SBen Gras 5232fe8fb19SBen Gras #if defined(_NETBSD_SOURCE) 5242fe8fb19SBen Gras 5252fe8fb19SBen Gras /* float versions of ANSI/POSIX functions */ 5262fe8fb19SBen Gras 5272fe8fb19SBen Gras float gammaf(float); 5282fe8fb19SBen Gras int isinff(float); 5292fe8fb19SBen Gras int isnanf(float); 5302fe8fb19SBen Gras int finitef(float); 5312fe8fb19SBen Gras float j0f(float); 5322fe8fb19SBen Gras float j1f(float); 5332fe8fb19SBen Gras float jnf(int, float); 5342fe8fb19SBen Gras float y0f(float); 5352fe8fb19SBen Gras float y1f(float); 5362fe8fb19SBen Gras float ynf(int, float); 5372fe8fb19SBen Gras 5382fe8fb19SBen Gras float scalbf(float, float); 5392fe8fb19SBen Gras 5402fe8fb19SBen Gras /* 5412fe8fb19SBen Gras * float version of IEEE Test Vector 5422fe8fb19SBen Gras */ 5432fe8fb19SBen Gras float significandf(float); 5442fe8fb19SBen Gras 5452fe8fb19SBen Gras /* 5462fe8fb19SBen Gras * float versions of BSD math library entry points 5472fe8fb19SBen Gras */ 5482fe8fb19SBen Gras float dremf(float, float); 5492fe8fb19SBen Gras #endif /* _NETBSD_SOURCE */ 5502fe8fb19SBen Gras 5512fe8fb19SBen Gras #if defined(_NETBSD_SOURCE) || defined(_REENTRANT) 5522fe8fb19SBen Gras /* 5532fe8fb19SBen Gras * Float versions of reentrant version of gamma & lgamma; passes 5542fe8fb19SBen Gras * signgam back by reference as the second argument; user must 5552fe8fb19SBen Gras * allocate space for signgam. 5562fe8fb19SBen Gras */ 5572fe8fb19SBen Gras float gammaf_r(float, int *); 5582fe8fb19SBen Gras float lgammaf_r(float, int *); 5592fe8fb19SBen Gras #endif /* !... || _REENTRANT */ 5602fe8fb19SBen Gras 5612fe8fb19SBen Gras /* 5622fe8fb19SBen Gras * Library implementation 5632fe8fb19SBen Gras */ 5642fe8fb19SBen Gras int __fpclassifyf(float); 5652fe8fb19SBen Gras int __fpclassifyd(double); 5662fe8fb19SBen Gras int __isfinitef(float); 5672fe8fb19SBen Gras int __isfinited(double); 5682fe8fb19SBen Gras int __isinff(float); 5692fe8fb19SBen Gras int __isinfd(double); 5702fe8fb19SBen Gras int __isnanf(float); 5712fe8fb19SBen Gras int __isnand(double); 5722fe8fb19SBen Gras int __signbitf(float); 5732fe8fb19SBen Gras int __signbitd(double); 5742fe8fb19SBen Gras 5752fe8fb19SBen Gras #ifdef __HAVE_LONG_DOUBLE 5762fe8fb19SBen Gras int __fpclassifyl(long double); 5772fe8fb19SBen Gras int __isfinitel(long double); 5782fe8fb19SBen Gras int __isinfl(long double); 5792fe8fb19SBen Gras int __isnanl(long double); 5802fe8fb19SBen Gras int __signbitl(long double); 5812fe8fb19SBen Gras #endif 582f14fb602SLionel Sambuc 5832fe8fb19SBen Gras __END_DECLS 5842fe8fb19SBen Gras 5852fe8fb19SBen Gras #endif /* _MATH_H_ */ 586