1 /* $NetBSD: math.h,v 1.40 2005/02/03 04:39:32 perry Exp $ */
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
11 * ====================================================
13 * $NetBSD: math.h,v 1.40 2005/02/03 04:39:32 perry Exp $
14 * $DragonFly: src/include/math.h,v 1.5 2005/07/26 21:15:19 joerg Exp $
18 * @(#)fdlibm.h 5.1 93/09/24
24 #include <sys/cdefs.h>
27 unsigned char __dummy[sizeof(float)];
32 unsigned char __dummy[sizeof(double)];
36 union __long_double_u {
37 unsigned char __dummy[sizeof(long double)];
41 #include <machine/math.h>
43 #ifdef __HAVE_LONG_DOUBLE
44 #define __fpmacro_unary_floating(__name, __arg0) \
46 ((sizeof (__arg0) == sizeof (float)) \
47 ? __ ## __name ## f (__arg0) \
48 : (sizeof (__arg0) == sizeof (double)) \
49 ? __ ## __name ## d (__arg0) \
50 : __ ## __name ## l (__arg0))
52 #define __fpmacro_unary_floating(__name, __arg0) \
54 ((sizeof (__arg0) == sizeof (float)) \
55 ? __ ## __name ## f (__arg0) \
56 : __ ## __name ## d (__arg0))
57 #endif /* __HAVE_LONG_DOUBLE */
62 /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
63 extern __const union __double_u __infinity;
64 #define HUGE_VAL __infinity.__val
69 #if __ISO_C_VISIBLE >= 1999
70 /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
71 extern __const union __float_u __infinityf;
72 #define HUGE_VALF __infinityf.__val
74 extern __const union __long_double_u __infinityl;
75 #define HUGE_VALL __infinityl.__val
79 #define INFINITY __INFINITY /* float constant which overflows */
81 #define INFINITY HUGE_VALF /* positive infinity */
82 #endif /* __INFINITY */
84 /* 7.12#5 NAN: a quiet NaN, if supported */
86 extern __const union __float_u __nanf;
87 #define NAN __nanf.__val
88 #endif /* __HAVE_NANF */
90 /* 7.12#6 number classification macros */
91 #define FP_INFINITE 0x00
93 #define FP_NORMAL 0x02
94 #define FP_SUBNORMAL 0x03
96 /* NetBSD extensions */
97 #define _FP_LOMD 0x80 /* range for machine-specific classes */
105 #if __XSI_VISIBLE > 0
106 #define M_E 2.7182818284590452354 /* e */
107 #define M_LOG2E 1.4426950408889634074 /* log 2e */
108 #define M_LOG10E 0.43429448190325182765 /* log 10e */
109 #define M_LN2 0.69314718055994530942 /* log e2 */
110 #define M_LN10 2.30258509299404568402 /* log e10 */
111 #define M_PI 3.14159265358979323846 /* pi */
112 #define M_PI_2 1.57079632679489661923 /* pi/2 */
113 #define M_PI_4 0.78539816339744830962 /* pi/4 */
114 #define M_1_PI 0.31830988618379067154 /* 1/pi */
115 #define M_2_PI 0.63661977236758134308 /* 2/pi */
116 #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
117 #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
118 #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
120 #define MAXFLOAT ((float)3.40282346638528860e+38)
122 #endif /* _XSI_VISIBLE */
125 #define HUGE MAXFLOAT
128 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
129 * (one may replace the following line by "#include <values.h>")
132 #define X_TLOSS 1.41484755040568800000e+16
141 #endif /* __DF_VISIBLE */
150 double atan2(double, double);
160 double frexp(double, int *);
161 double ldexp(double, int);
163 double log10(double);
164 double modf(double, double *);
166 double pow(double, double);
171 double floor(double);
172 double fmod(double, double);
174 #if __XSI_VISIBLE > 0
177 double gamma(double);
178 double hypot(double, double);
182 double jn(int, double);
183 double lgamma(double);
186 double yn(int, double);
187 #endif /* __XSI_VISIBLE */
189 #if __XSI_VISIBLE >= 500
190 double acosh(double);
191 double asinh(double);
192 double atanh(double);
194 double expm1(double);
196 double log1p(double);
198 double nextafter(double, double);
199 double remainder(double, double);
201 double scalb(double, double);
202 #endif /* __XSI_VISIBLE >= 500 */
207 #if __ISO_C_VISIBLE >= 1999
208 /* 7.12.3.1 int fpclassify(real-floating x) */
209 #define fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x)
211 /* 7.12.3.2 int isfinite(real-floating x) */
212 #define isfinite(__x) __fpmacro_unary_floating(isfinite, __x)
214 /* 7.12.3.5 int isnormal(real-floating x) */
215 #define isnormal(__x) (fpclassify(__x) == FP_NORMAL)
217 /* 7.12.3.6 int signbit(real-floating x) */
218 #define signbit(__x) __fpmacro_unary_floating(signbit, __x)
220 /* 7.12.4 trigonometric */
225 float atan2f(float, float);
230 /* 7.12.5 hyperbolic */
239 /* 7.12.6 exp / log */
243 float frexpf(float, int *);
245 float ldexpf(float, int);
250 float modff(float, float *);
251 float scalbnf(float, int);
253 /* 7.12.7 power / absolute */
257 float hypotf(float, float);
258 float powf(float, float);
261 /* 7.12.8 error / gamma */
265 float lgammaf(float);
267 /* 7.12.9 nearest integer */
272 double round(double);
274 long int lrint(double);
275 long int lrintf(float);
277 long long int llrint(double);
279 long long int llrintf(float);
280 long int lround(double);
281 long int lroundf(float);
283 long long int llround(double);
285 long long int llroundf(float);
287 /* 7.12.10 remainder */
289 float fmodf(float, float);
290 float remainderf(float, float);
292 /* 7.2.11 manipulation */
294 float copysignf(float, float);
295 float nextafterf(float, float);
297 #endif /* __ISO_C_VISIBLE >= 1999 */
299 #if __ISO_C_VISIBLE >= 1999
300 /* 7.12.3.3 int isinf(real-floating x) */
302 #define isinf(__x) __isinf(__x)
304 #define isinf(__x) __fpmacro_unary_floating(isinf, __x)
307 /* 7.12.3.4 int isnan(real-floating x) */
309 #define isnan(__x) __isnan(__x)
311 #define isnan(__x) __fpmacro_unary_floating(isnan, __x)
313 #endif /* __ISO_C_VISIBLE >= 1999 */
319 double significand(double);
322 * Functions callable from C, intended to support IEEE arithmetic.
324 double copysign(double, double);
325 double scalbn(double, int);
328 * BSD math library entry points
330 double drem(double, double);
333 * Reentrant version of gamma & lgamma; passes signgam back by reference
334 * as the second argument; user must allocate space for signgam.
336 double gamma_r(double, int *);
337 double lgamma_r(double, int *);
338 #endif /* __DF_VISIBLE */
343 /* float versions of ANSI/POSIX functions */
351 float jnf(int, float);
354 float ynf(int, float);
356 float scalbf(float, float);
359 * float version of IEEE Test Vector
361 float significandf(float);
364 * float versions of BSD math library entry points
366 float dremf(float, float);
369 * Float versions of reentrant version of gamma & lgamma; passes
370 * signgam back by reference as the second argument; user must
371 * allocate space for signgam.
373 float gammaf_r(float, int *);
374 float lgammaf_r(float, int *);
375 #endif /* __DF_VISIBLE */
378 * Library implementation
380 int __fpclassifyf(float);
381 int __fpclassifyd(double);
382 int __isfinitef(float);
383 int __isfinited(double);
385 int __isinfd(double);
387 int __isnand(double);
388 int __signbitf(float);
389 int __signbitd(double);
391 #ifdef __HAVE_LONG_DOUBLE
392 int __fpclassifyl(long double);
393 int __isfinitel(long double);
394 int __isinfl(long double);
395 int __isnanl(long double);
396 int __signbitl(long double);
400 #endif /* _MATH_H_ */