Home | History | Annotate | Line # | Download | only in include
math.h revision 1.71
      1  1.71  riastrad /*	$NetBSD: math.h,v 1.71 2024/09/09 15:05:51 riastradh Exp $	*/
      2  1.10       cgd 
      3   1.1       cgd /*
      4   1.6       jtc  * ====================================================
      5   1.6       jtc  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
      6   1.1       cgd  *
      7   1.6       jtc  * Developed at SunPro, a Sun Microsystems, Inc. business.
      8   1.6       jtc  * Permission to use, copy, modify, and distribute this
      9  1.38  junyoung  * software is freely granted, provided that this notice
     10   1.6       jtc  * is preserved.
     11   1.6       jtc  * ====================================================
     12   1.1       cgd  */
     13   1.1       cgd 
     14   1.6       jtc /*
     15  1.10       cgd  * @(#)fdlibm.h 5.1 93/09/24
     16   1.6       jtc  */
     17   1.1       cgd 
     18   1.6       jtc #ifndef _MATH_H_
     19   1.7       cgd #define _MATH_H_
     20   1.1       cgd 
     21  1.21    kleink #include <sys/cdefs.h>
     22  1.12    kleink #include <sys/featuretest.h>
     23  1.24    simonb 
     24  1.66     joerg /*
     25  1.66     joerg  * Missing for C99 support:
     26  1.66     joerg  * - MATH_ERRNO
     27  1.66     joerg  * - MATH_ERREXCEPT
     28  1.66     joerg  * - math_errhandling
     29  1.66     joerg  */
     30  1.66     joerg 
     31  1.24    simonb union __float_u {
     32  1.24    simonb 	unsigned char __dummy[sizeof(float)];
     33  1.24    simonb 	float __val;
     34  1.24    simonb };
     35  1.24    simonb 
     36  1.24    simonb union __double_u {
     37  1.24    simonb 	unsigned char __dummy[sizeof(double)];
     38  1.24    simonb 	double __val;
     39  1.24    simonb };
     40  1.24    simonb 
     41  1.26   thorpej union __long_double_u {
     42  1.26   thorpej 	unsigned char __dummy[sizeof(long double)];
     43  1.26   thorpej 	long double __val;
     44  1.26   thorpej };
     45  1.26   thorpej 
     46  1.26   thorpej #include <machine/math.h>		/* may use __float_u, __double_u,
     47  1.26   thorpej 					   or __long_double_u */
     48  1.60      matt #include <limits.h>			/* for INT_{MIN,MAX} */
     49  1.12    kleink 
     50  1.66     joerg #if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
     51  1.66     joerg     !defined(_XOPEN_SOURCE)) || ((_POSIX_C_SOURCE - 0) >= 200809L || \
     52  1.66     joerg      defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \
     53  1.66     joerg      (__cplusplus - 0) >= 201103L || defined(_NETBSD_SOURCE))
     54  1.66     joerg #define __MATH_C99_FEATURES
     55  1.66     joerg #endif
     56  1.66     joerg 
     57  1.66     joerg #ifdef __MATH_C99_FEATURES
     58  1.62     joerg #  if defined(__FLT_EVAL_METHOD__) && (__FLT_EVAL_METHOD__ - 0) == 0
     59  1.62     joerg typedef double double_t;
     60  1.62     joerg typedef float float_t;
     61  1.62     joerg #  elif (__FLT_EVAL_METHOD__ - 0) == 1
     62  1.62     joerg typedef double double_t;
     63  1.62     joerg typedef double float_t;
     64  1.62     joerg #  elif (__FLT_EVAL_METHOD__ - 0) == 2
     65  1.62     joerg typedef long double double_t;
     66  1.62     joerg typedef long double float_t;
     67  1.62     joerg #  endif
     68  1.62     joerg #endif
     69  1.62     joerg 
     70  1.29    kleink #ifdef __HAVE_LONG_DOUBLE
     71  1.29    kleink #define	__fpmacro_unary_floating(__name, __arg0)			\
     72  1.33    kleink 	/* LINTED */							\
     73  1.29    kleink 	((sizeof (__arg0) == sizeof (float))				\
     74  1.29    kleink 	?	__ ## __name ## f (__arg0)				\
     75  1.29    kleink 	: (sizeof (__arg0) == sizeof (double))				\
     76  1.29    kleink 	?	__ ## __name ## d (__arg0)				\
     77  1.29    kleink 	:	__ ## __name ## l (__arg0))
     78  1.29    kleink #else
     79  1.29    kleink #define	__fpmacro_unary_floating(__name, __arg0)			\
     80  1.33    kleink 	/* LINTED */							\
     81  1.29    kleink 	((sizeof (__arg0) == sizeof (float))				\
     82  1.29    kleink 	?	__ ## __name ## f (__arg0)				\
     83  1.29    kleink 	:	__ ## __name ## d (__arg0))
     84  1.30       uwe #endif /* __HAVE_LONG_DOUBLE */
     85  1.29    kleink 
     86   1.1       cgd /*
     87   1.6       jtc  * ANSI/POSIX
     88   1.6       jtc  */
     89  1.28    kleink /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
     90  1.51     joerg #if __GNUC_PREREQ__(3, 3)
     91  1.51     joerg #define HUGE_VAL	__builtin_huge_val()
     92  1.51     joerg #else
     93  1.42     perry extern const union __double_u __infinity;
     94  1.24    simonb #define HUGE_VAL	__infinity.__val
     95  1.51     joerg #endif
     96  1.24    simonb 
     97  1.24    simonb /*
     98  1.24    simonb  * ISO C99
     99  1.24    simonb  */
    100  1.66     joerg #if defined(__MATH_C99_FEATURES) || \
    101  1.66     joerg     (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE  - 0) >= 600
    102  1.28    kleink /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
    103  1.51     joerg #if __GNUC_PREREQ__(3, 3)
    104  1.51     joerg #define	HUGE_VALF	__builtin_huge_valf()
    105  1.51     joerg #define	HUGE_VALL	__builtin_huge_vall()
    106  1.51     joerg #else
    107  1.42     perry extern const union __float_u __infinityf;
    108  1.27    kleink #define	HUGE_VALF	__infinityf.__val
    109  1.27    kleink 
    110  1.42     perry extern const union __long_double_u __infinityl;
    111  1.27    kleink #define	HUGE_VALL	__infinityl.__val
    112  1.51     joerg #endif
    113  1.27    kleink 
    114  1.28    kleink /* 7.12#4 INFINITY */
    115  1.57      matt #if defined(__INFINITY)
    116  1.57      matt #define	INFINITY	__INFINITY	/* float constant which overflows */
    117  1.57      matt #elif __GNUC_PREREQ__(3, 3)
    118  1.51     joerg #define	INFINITY	__builtin_inff()
    119  1.28    kleink #else
    120  1.28    kleink #define	INFINITY	HUGE_VALF	/* positive infinity */
    121  1.28    kleink #endif /* __INFINITY */
    122  1.28    kleink 
    123  1.28    kleink /* 7.12#5 NAN: a quiet NaN, if supported */
    124  1.27    kleink #ifdef __HAVE_NANF
    125  1.48    martin #if __GNUC_PREREQ__(3,3)
    126  1.48    martin #define	NAN	__builtin_nanf("")
    127  1.48    martin #else
    128  1.42     perry extern const union __float_u __nanf;
    129  1.24    simonb #define	NAN		__nanf.__val
    130  1.48    martin #endif
    131  1.27    kleink #endif /* __HAVE_NANF */
    132  1.29    kleink 
    133  1.29    kleink /* 7.12#6 number classification macros */
    134  1.29    kleink #define	FP_INFINITE	0x00
    135  1.29    kleink #define	FP_NAN		0x01
    136  1.29    kleink #define	FP_NORMAL	0x02
    137  1.29    kleink #define	FP_SUBNORMAL	0x03
    138  1.29    kleink #define	FP_ZERO		0x04
    139  1.29    kleink /* NetBSD extensions */
    140  1.29    kleink #define	_FP_LOMD	0x80		/* range for machine-specific classes */
    141  1.29    kleink #define	_FP_HIMD	0xff
    142  1.29    kleink 
    143  1.71  riastrad /* 7.12#7 fast fma(3) feature test macros */
    144  1.71  riastrad #if __GNUC_PREREQ__(4, 4)
    145  1.71  riastrad #  ifdef __FP_FAST_FMA
    146  1.71  riastrad #    define	FP_FAST_FMA	1
    147  1.71  riastrad #  endif
    148  1.71  riastrad #  ifdef __FP_FAST_FMAF
    149  1.71  riastrad #    define	FP_FAST_FMAF	1
    150  1.71  riastrad #  endif
    151  1.71  riastrad #  ifdef __FP_FAST_FMAL
    152  1.71  riastrad #    define	FP_FAST_FMAL	1
    153  1.71  riastrad #  endif
    154  1.71  riastrad #endif
    155  1.71  riastrad 
    156  1.71  riastrad /* 7.12#8 ilogb exceptional input result value macros */
    157  1.60      matt #define	FP_ILOGB0	INT_MIN
    158  1.61      matt #define	FP_ILOGBNAN	INT_MAX
    159  1.60      matt 
    160  1.66     joerg #endif /* C99 || _XOPEN_SOURCE >= 600 */
    161   1.1       cgd 
    162   1.6       jtc /*
    163   1.6       jtc  * XOPEN/SVID
    164   1.6       jtc  */
    165  1.25     bjh21 #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
    166   1.1       cgd #define	M_E		2.7182818284590452354	/* e */
    167   1.1       cgd #define	M_LOG2E		1.4426950408889634074	/* log 2e */
    168   1.1       cgd #define	M_LOG10E	0.43429448190325182765	/* log 10e */
    169   1.1       cgd #define	M_LN2		0.69314718055994530942	/* log e2 */
    170   1.1       cgd #define	M_LN10		2.30258509299404568402	/* log e10 */
    171   1.1       cgd #define	M_PI		3.14159265358979323846	/* pi */
    172   1.1       cgd #define	M_PI_2		1.57079632679489661923	/* pi/2 */
    173   1.1       cgd #define	M_PI_4		0.78539816339744830962	/* pi/4 */
    174   1.1       cgd #define	M_1_PI		0.31830988618379067154	/* 1/pi */
    175   1.1       cgd #define	M_2_PI		0.63661977236758134308	/* 2/pi */
    176   1.1       cgd #define	M_2_SQRTPI	1.12837916709551257390	/* 2/sqrt(pi) */
    177   1.1       cgd #define	M_SQRT2		1.41421356237309504880	/* sqrt(2) */
    178   1.1       cgd #define	M_SQRT1_2	0.70710678118654752440	/* 1/sqrt(2) */
    179   1.6       jtc 
    180   1.6       jtc #define	MAXFLOAT	((float)3.40282346638528860e+38)
    181   1.6       jtc extern int signgam;
    182  1.25     bjh21 #endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
    183   1.6       jtc 
    184  1.25     bjh21 #if defined(_NETBSD_SOURCE)
    185   1.6       jtc enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
    186   1.6       jtc 
    187   1.6       jtc #define _LIB_VERSION_TYPE enum fdversion
    188  1.38  junyoung #define _LIB_VERSION _fdlib_version
    189   1.6       jtc 
    190  1.38  junyoung /* if global variable _LIB_VERSION is not desirable, one may
    191  1.38  junyoung  * change the following to be a constant by:
    192   1.6       jtc  *	#define _LIB_VERSION_TYPE const enum version
    193   1.6       jtc  * In that case, after one initializes the value _LIB_VERSION (see
    194   1.6       jtc  * s_lib_version.c) during compile time, it cannot be modified
    195   1.6       jtc  * in the middle of a program
    196  1.38  junyoung  */
    197   1.6       jtc extern  _LIB_VERSION_TYPE  _LIB_VERSION;
    198   1.6       jtc 
    199   1.6       jtc #define _IEEE_  fdlibm_ieee
    200   1.6       jtc #define _SVID_  fdlibm_svid
    201   1.6       jtc #define _XOPEN_ fdlibm_xopen
    202   1.6       jtc #define _POSIX_ fdlibm_posix
    203   1.6       jtc 
    204  1.11        tv #ifndef __cplusplus
    205   1.6       jtc struct exception {
    206   1.6       jtc 	int type;
    207  1.47  christos 	const char *name;
    208   1.6       jtc 	double arg1;
    209   1.6       jtc 	double arg2;
    210   1.6       jtc 	double retval;
    211   1.6       jtc };
    212  1.11        tv #endif
    213   1.6       jtc 
    214   1.6       jtc #define	HUGE		MAXFLOAT
    215   1.6       jtc 
    216  1.38  junyoung /*
    217   1.6       jtc  * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
    218   1.6       jtc  * (one may replace the following line by "#include <values.h>")
    219   1.6       jtc  */
    220   1.6       jtc 
    221  1.38  junyoung #define X_TLOSS		1.41484755040568800000e+16
    222   1.6       jtc 
    223   1.6       jtc #define	DOMAIN		1
    224   1.6       jtc #define	SING		2
    225   1.6       jtc #define	OVERFLOW	3
    226   1.6       jtc #define	UNDERFLOW	4
    227   1.6       jtc #define	TLOSS		5
    228   1.6       jtc #define	PLOSS		6
    229   1.6       jtc 
    230  1.25     bjh21 #endif /* _NETBSD_SOURCE */
    231   1.6       jtc 
    232   1.1       cgd __BEGIN_DECLS
    233   1.6       jtc /*
    234   1.6       jtc  * ANSI/POSIX
    235   1.6       jtc  */
    236  1.40     perry double	acos(double);
    237  1.40     perry double	asin(double);
    238  1.40     perry double	atan(double);
    239  1.40     perry double	atan2(double, double);
    240  1.40     perry double	cos(double);
    241  1.40     perry double	sin(double);
    242  1.40     perry double	tan(double);
    243  1.40     perry 
    244  1.40     perry double	cosh(double);
    245  1.40     perry double	sinh(double);
    246  1.40     perry double	tanh(double);
    247  1.40     perry 
    248  1.40     perry double	exp(double);
    249  1.50  christos double	exp2(double);
    250  1.40     perry double	frexp(double, int *);
    251  1.40     perry double	ldexp(double, int);
    252  1.40     perry double	log(double);
    253  1.41  christos double	log2(double);
    254  1.40     perry double	log10(double);
    255  1.40     perry double	modf(double, double *);
    256  1.40     perry 
    257  1.40     perry double	pow(double, double);
    258  1.40     perry double	sqrt(double);
    259  1.40     perry 
    260  1.40     perry double	ceil(double);
    261  1.40     perry double	fabs(double);
    262  1.40     perry double	floor(double);
    263  1.40     perry double	fmod(double, double);
    264   1.1       cgd 
    265  1.66     joerg #if defined(__MATH_C99_FEATURES) || defined(_XOPEN_SOURCE)
    266  1.40     perry double	erf(double);
    267  1.40     perry double	erfc(double);
    268  1.40     perry double	hypot(double, double);
    269  1.66     joerg #endif
    270  1.66     joerg 
    271  1.66     joerg #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
    272  1.40     perry int	finite(double);
    273  1.66     joerg double	gamma(double);
    274  1.40     perry double	j0(double);
    275  1.40     perry double	j1(double);
    276  1.40     perry double	jn(int, double);
    277  1.40     perry double	y0(double);
    278  1.40     perry double	y1(double);
    279  1.40     perry double	yn(int, double);
    280   1.6       jtc 
    281  1.25     bjh21 #if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
    282  1.65  christos double	scalb(double, double);
    283  1.65  christos #endif /* (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)*/
    284  1.65  christos #endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */
    285  1.65  christos 
    286  1.65  christos /*
    287  1.65  christos  * ISO C99
    288  1.65  christos  */
    289  1.66     joerg #if defined(__MATH_C99_FEATURES) || (_XOPEN_SOURCE - 0) >= 500
    290  1.40     perry double	acosh(double);
    291  1.40     perry double	asinh(double);
    292  1.40     perry double	atanh(double);
    293  1.40     perry double	cbrt(double);
    294  1.40     perry double	expm1(double);
    295  1.40     perry int	ilogb(double);
    296  1.40     perry double	log1p(double);
    297  1.40     perry double	logb(double);
    298  1.40     perry double	nextafter(double, double);
    299  1.40     perry double	remainder(double, double);
    300  1.65  christos double	rint(double);
    301  1.65  christos #endif
    302   1.6       jtc 
    303  1.66     joerg #if defined(__MATH_C99_FEATURES) || (_XOPEN_SOURCE - 0) >= 600 || \
    304  1.66     joerg     (_POSIX_C_SOURCE - 0) >= 200112L
    305  1.29    kleink /* 7.12.3.1 int fpclassify(real-floating x) */
    306  1.29    kleink #define	fpclassify(__x)	__fpmacro_unary_floating(fpclassify, __x)
    307  1.29    kleink 
    308  1.29    kleink /* 7.12.3.2 int isfinite(real-floating x) */
    309  1.29    kleink #define	isfinite(__x)	__fpmacro_unary_floating(isfinite, __x)
    310  1.29    kleink 
    311  1.29    kleink /* 7.12.3.5 int isnormal(real-floating x) */
    312  1.29    kleink #define	isnormal(__x)	(fpclassify(__x) == FP_NORMAL)
    313  1.29    kleink 
    314  1.29    kleink /* 7.12.3.6 int signbit(real-floating x) */
    315  1.29    kleink #define	signbit(__x)	__fpmacro_unary_floating(signbit, __x)
    316  1.29    kleink 
    317  1.35  drochner /* 7.12.4 trigonometric */
    318  1.35  drochner 
    319  1.40     perry float	acosf(float);
    320  1.40     perry float	asinf(float);
    321  1.40     perry float	atanf(float);
    322  1.40     perry float	atan2f(float, float);
    323  1.40     perry float	cosf(float);
    324  1.40     perry float	sinf(float);
    325  1.40     perry float	tanf(float);
    326  1.35  drochner 
    327  1.59      matt long double	acosl(long double);
    328  1.59      matt long double	asinl(long double);
    329  1.59      matt long double	atanl(long double);
    330  1.59      matt long double	atan2l(long double, long double);
    331  1.59      matt long double	cosl(long double);
    332  1.59      matt long double	sinl(long double);
    333  1.59      matt long double	tanl(long double);
    334  1.59      matt 
    335  1.35  drochner /* 7.12.5 hyperbolic */
    336  1.35  drochner 
    337  1.40     perry float	acoshf(float);
    338  1.40     perry float	asinhf(float);
    339  1.40     perry float	atanhf(float);
    340  1.40     perry float	coshf(float);
    341  1.40     perry float	sinhf(float);
    342  1.40     perry float	tanhf(float);
    343  1.59      matt long double	acoshl(long double);
    344  1.59      matt long double	asinhl(long double);
    345  1.59      matt long double	atanhl(long double);
    346  1.59      matt long double	coshl(long double);
    347  1.59      matt long double	sinhl(long double);
    348  1.59      matt long double	tanhl(long double);
    349  1.35  drochner 
    350  1.35  drochner /* 7.12.6 exp / log */
    351  1.66     joerg double	scalbn(double, int);
    352  1.66     joerg double	scalbln(double, long);
    353  1.35  drochner 
    354  1.40     perry float	expf(float);
    355  1.50  christos float	exp2f(float);
    356  1.40     perry float	expm1f(float);
    357  1.40     perry float	frexpf(float, int *);
    358  1.40     perry int	ilogbf(float);
    359  1.40     perry float	ldexpf(float, int);
    360  1.40     perry float	logf(float);
    361  1.41  christos float	log2f(float);
    362  1.40     perry float	log10f(float);
    363  1.40     perry float	log1pf(float);
    364  1.40     perry float	logbf(float);
    365  1.40     perry float	modff(float, float *);
    366  1.40     perry float	scalbnf(float, int);
    367  1.59      matt float	scalblnf(float, long);
    368  1.59      matt 
    369  1.59      matt long double	expl(long double);
    370  1.59      matt long double	exp2l(long double);
    371  1.59      matt long double	expm1l(long double);
    372  1.59      matt long double	frexpl(long double, int *);
    373  1.59      matt int		ilogbl(long double);
    374  1.59      matt long double	ldexpl(long double, int);
    375  1.59      matt long double	logl(long double);
    376  1.59      matt long double	log2l(long double);
    377  1.59      matt long double	log10l(long double);
    378  1.59      matt long double	log1pl(long double);
    379  1.59      matt long double	logbl(long double);
    380  1.59      matt long double	modfl(long double, long double *);
    381  1.59      matt long double	scalbnl(long double, int);
    382  1.59      matt long double	scalblnl(long double, long);
    383  1.59      matt 
    384  1.35  drochner 
    385  1.35  drochner /* 7.12.7 power / absolute */
    386  1.35  drochner 
    387  1.40     perry float	cbrtf(float);
    388  1.40     perry float	fabsf(float);
    389  1.40     perry float	hypotf(float, float);
    390  1.40     perry float	powf(float, float);
    391  1.40     perry float	sqrtf(float);
    392  1.59      matt long double	cbrtl(long double);
    393  1.59      matt long double	fabsl(long double);
    394  1.59      matt long double	hypotl(long double, long double);
    395  1.59      matt long double	powl(long double, long double);
    396  1.59      matt long double	sqrtl(long double);
    397  1.35  drochner 
    398  1.35  drochner /* 7.12.8 error / gamma */
    399  1.35  drochner 
    400  1.66     joerg double	lgamma(double);
    401  1.59      matt double	tgamma(double);
    402  1.40     perry float	erff(float);
    403  1.40     perry float	erfcf(float);
    404  1.40     perry float	lgammaf(float);
    405  1.58  christos float	tgammaf(float);
    406  1.59      matt long double	erfl(long double);
    407  1.59      matt long double	erfcl(long double);
    408  1.59      matt long double	lgammal(long double);
    409  1.59      matt long double	tgammal(long double);
    410  1.35  drochner 
    411  1.35  drochner /* 7.12.9 nearest integer */
    412  1.65  christos 
    413  1.59      matt /* LONGLONG */
    414  1.59      matt long long int	llrint(double);
    415  1.59      matt long int	lround(double);
    416  1.59      matt /* LONGLONG */
    417  1.59      matt long long int	llround(double);
    418  1.59      matt long int	lrint(double);
    419  1.59      matt double	round(double);
    420  1.59      matt double	trunc(double);
    421  1.59      matt 
    422  1.40     perry float	ceilf(float);
    423  1.40     perry float	floorf(float);
    424  1.59      matt /* LONGLONG */
    425  1.59      matt long long int	llrintf(float);
    426  1.59      matt long int	lroundf(float);
    427  1.59      matt /* LONGLONG */
    428  1.59      matt long long int	llroundf(float);
    429  1.59      matt long int	lrintf(float);
    430  1.40     perry float	rintf(float);
    431  1.40     perry float	roundf(float);
    432  1.44   xtraeme float	truncf(float);
    433  1.59      matt long double	ceill(long double);
    434  1.59      matt long double	floorl(long double);
    435  1.36  drochner /* LONGLONG */
    436  1.59      matt long long int	llrintl(long double);
    437  1.59      matt long int	lroundl(long double);
    438  1.37  drochner /* LONGLONG */
    439  1.59      matt long long int	llroundl(long double);
    440  1.59      matt long int	lrintl(long double);
    441  1.59      matt long double	rintl(long double);
    442  1.59      matt long double	roundl(long double);
    443  1.59      matt long double	truncl(long double);
    444  1.35  drochner 
    445  1.35  drochner /* 7.12.10 remainder */
    446  1.35  drochner 
    447  1.40     perry float	fmodf(float, float);
    448  1.40     perry float	remainderf(float, float);
    449  1.59      matt long double	fmodl(long double, long double);
    450  1.59      matt long double	remainderl(long double, long double);
    451  1.35  drochner 
    452  1.54  christos /* 7.12.10.3 The remquo functions */
    453  1.54  christos double	remquo(double, double, int *);
    454  1.54  christos float	remquof(float, float, int *);
    455  1.59      matt long double	remquol(long double, long double, int *);
    456  1.54  christos 
    457  1.45  drochner /* 7.12.11 manipulation */
    458  1.35  drochner 
    459  1.66     joerg double	copysign(double, double);
    460  1.59      matt double	nan(const char *);
    461  1.59      matt double	nearbyint(double);
    462  1.59      matt double	nexttoward(double, long double);
    463  1.40     perry float	copysignf(float, float);
    464  1.59      matt float	nanf(const char *);
    465  1.59      matt float	nearbyintf(float);
    466  1.59      matt float	nextafterf(float, float);
    467  1.59      matt float	nexttowardf(float, long double);
    468  1.53  christos long double	copysignl(long double, long double);
    469  1.43    kleink long double	nanl(const char *);
    470  1.59      matt long double	nearbyintl(long double);
    471  1.53  christos long double     nextafterl(long double, long double);
    472  1.59      matt long double	nexttowardl(long double, long double);
    473  1.35  drochner 
    474  1.52  dholland /* 7.12.14 comparison */
    475  1.45  drochner 
    476  1.45  drochner #define isunordered(x, y)	(isnan(x) || isnan(y))
    477  1.45  drochner #define isgreater(x, y)		(!isunordered((x), (y)) && (x) > (y))
    478  1.45  drochner #define isgreaterequal(x, y)	(!isunordered((x), (y)) && (x) >= (y))
    479  1.45  drochner #define isless(x, y)		(!isunordered((x), (y)) && (x) < (y))
    480  1.45  drochner #define islessequal(x, y)	(!isunordered((x), (y)) && (x) <= (y))
    481  1.45  drochner #define islessgreater(x, y)	(!isunordered((x), (y)) && \
    482  1.45  drochner 				 ((x) > (y) || (y) > (x)))
    483  1.49  christos double	fdim(double, double);
    484  1.59      matt double	fma(double, double, double);
    485  1.49  christos double	fmax(double, double);
    486  1.49  christos double	fmin(double, double);
    487  1.49  christos float	fdimf(float, float);
    488  1.59      matt float	fmaf(float, float, float);
    489  1.49  christos float	fmaxf(float, float);
    490  1.49  christos float	fminf(float, float);
    491  1.49  christos long double fdiml(long double, long double);
    492  1.59      matt long double fmal(long double, long double, long double);
    493  1.49  christos long double fmaxl(long double, long double);
    494  1.49  christos long double fminl(long double, long double);
    495  1.35  drochner 
    496  1.29    kleink #endif /* !_ANSI_SOURCE && ... */
    497  1.29    kleink 
    498  1.66     joerg #if defined(__MATH_C99_FEATURES) || (_POSIX_C_SOURCE - 0) >= 200112L
    499  1.34    kleink /* 7.12.3.3 int isinf(real-floating x) */
    500  1.63    martin #if defined(__isinf) || defined(__HAVE_INLINE___ISINF)
    501  1.34    kleink #define	isinf(__x)	__isinf(__x)
    502  1.34    kleink #else
    503  1.34    kleink #define	isinf(__x)	__fpmacro_unary_floating(isinf, __x)
    504  1.34    kleink #endif
    505  1.34    kleink 
    506  1.34    kleink /* 7.12.3.4 int isnan(real-floating x) */
    507  1.63    martin #if defined(__isnan) || defined(__HAVE_INLINE___ISNAN)
    508  1.34    kleink #define	isnan(__x)	__isnan(__x)
    509  1.34    kleink #else
    510  1.34    kleink #define	isnan(__x)	__fpmacro_unary_floating(isnan, __x)
    511  1.34    kleink #endif
    512  1.34    kleink #endif /* !_ANSI_SOURCE && ... */
    513  1.34    kleink 
    514  1.25     bjh21 #if defined(_NETBSD_SOURCE)
    515  1.70  riastrad 
    516  1.11        tv #ifndef __cplusplus
    517  1.40     perry int	matherr(struct exception *);
    518  1.11        tv #endif
    519   1.6       jtc 
    520   1.6       jtc /*
    521   1.6       jtc  * IEEE Test Vector
    522   1.6       jtc  */
    523  1.40     perry double	significand(double);
    524   1.1       cgd 
    525   1.6       jtc /*
    526   1.6       jtc  * BSD math library entry points
    527   1.6       jtc  */
    528  1.40     perry double	drem(double, double);
    529   1.6       jtc 
    530  1.70  riastrad void		sincos(double, double *, double *);
    531  1.70  riastrad void		sincosf(float, float *, float *);
    532  1.70  riastrad void		sincosl(long double, long double *, long double *);
    533  1.70  riastrad 
    534  1.70  riastrad double		cospi(double);
    535  1.70  riastrad float		cospif(float);
    536  1.70  riastrad long double	cospil(long double);
    537  1.70  riastrad 
    538  1.70  riastrad double		sinpi(double);
    539  1.70  riastrad float		sinpif(float);
    540  1.70  riastrad long double	sinpil(long double);
    541  1.70  riastrad 
    542  1.70  riastrad double		tanpi(double);
    543  1.70  riastrad float		tanpif(float);
    544  1.70  riastrad long double	tanpil(long double);
    545  1.70  riastrad 
    546  1.25     bjh21 #endif /* _NETBSD_SOURCE */
    547  1.12    kleink 
    548  1.25     bjh21 #if defined(_NETBSD_SOURCE) || defined(_REENTRANT)
    549   1.6       jtc /*
    550   1.6       jtc  * Reentrant version of gamma & lgamma; passes signgam back by reference
    551   1.6       jtc  * as the second argument; user must allocate space for signgam.
    552   1.6       jtc  */
    553  1.40     perry double	gamma_r(double, int *);
    554  1.40     perry double	lgamma_r(double, int *);
    555  1.70  riastrad long double	lgammal_r(long double, int *);
    556  1.25     bjh21 #endif /* _NETBSD_SOURCE || _REENTRANT */
    557   1.9       jtc 
    558  1.25     bjh21 #if defined(_NETBSD_SOURCE)
    559  1.15    kleink 
    560   1.9       jtc /* float versions of ANSI/POSIX functions */
    561  1.22    simonb 
    562  1.40     perry float	gammaf(float);
    563  1.40     perry int	isinff(float);
    564  1.40     perry int	isnanf(float);
    565  1.40     perry int	finitef(float);
    566  1.40     perry float	j0f(float);
    567  1.40     perry float	j1f(float);
    568  1.40     perry float	jnf(int, float);
    569  1.40     perry float	y0f(float);
    570  1.40     perry float	y1f(float);
    571  1.40     perry float	ynf(int, float);
    572  1.22    simonb 
    573  1.40     perry float	scalbf(float, float);
    574   1.9       jtc 
    575   1.9       jtc /*
    576   1.9       jtc  * float version of IEEE Test Vector
    577   1.9       jtc  */
    578  1.40     perry float	significandf(float);
    579   1.9       jtc 
    580   1.9       jtc /*
    581   1.9       jtc  * float versions of BSD math library entry points
    582   1.9       jtc  */
    583  1.40     perry float	dremf(float, float);
    584  1.25     bjh21 #endif /* _NETBSD_SOURCE */
    585   1.9       jtc 
    586  1.25     bjh21 #if defined(_NETBSD_SOURCE) || defined(_REENTRANT)
    587   1.9       jtc /*
    588   1.9       jtc  * Float versions of reentrant version of gamma & lgamma; passes
    589   1.9       jtc  * signgam back by reference as the second argument; user must
    590   1.9       jtc  * allocate space for signgam.
    591   1.9       jtc  */
    592  1.40     perry float	gammaf_r(float, int *);
    593  1.40     perry float	lgammaf_r(float, int *);
    594  1.12    kleink #endif /* !... || _REENTRANT */
    595   1.9       jtc 
    596  1.29    kleink /*
    597  1.29    kleink  * Library implementation
    598  1.29    kleink  */
    599  1.40     perry int	__fpclassifyf(float);
    600  1.40     perry int	__fpclassifyd(double);
    601  1.40     perry int	__isfinitef(float);
    602  1.40     perry int	__isfinited(double);
    603  1.40     perry int	__isinff(float);
    604  1.40     perry int	__isinfd(double);
    605  1.40     perry int	__isnanf(float);
    606  1.40     perry int	__isnand(double);
    607  1.40     perry int	__signbitf(float);
    608  1.40     perry int	__signbitd(double);
    609  1.29    kleink 
    610  1.29    kleink #ifdef __HAVE_LONG_DOUBLE
    611  1.40     perry int	__fpclassifyl(long double);
    612  1.40     perry int	__isfinitel(long double);
    613  1.40     perry int	__isinfl(long double);
    614  1.40     perry int	__isnanl(long double);
    615  1.40     perry int	__signbitl(long double);
    616  1.29    kleink #endif
    617  1.55     joerg 
    618   1.1       cgd __END_DECLS
    619   1.1       cgd 
    620   1.1       cgd #endif /* _MATH_H_ */
    621