Import entire msun from FreeBSD.

This commit is contained in:
Viral B. Shah 2011-12-15 11:29:35 +05:30
parent db4db9cf35
commit 16b9264f9d
304 changed files with 11767 additions and 1016 deletions

212
Makefile Normal file
View file

@ -0,0 +1,212 @@
# @(#)Makefile 5.1beta 93/09/24
# $FreeBSD: src/lib/msun/Makefile,v 1.112 2011/10/21 06:27:56 das Exp $
#
# ====================================================
# Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
#
# Developed at SunPro, a Sun Microsystems, Inc. business.
# Permission to use, copy, modify, and distribute this
# software is freely granted, provided that this notice
# is preserved.
# ====================================================
#
#
.if ${MACHINE_CPUARCH} == "i386"
ARCH_SUBDIR= i387
.else
ARCH_SUBDIR= ${MACHINE_CPUARCH}
.endif
.include "${ARCH_SUBDIR}/Makefile.inc"
.PATH: ${.CURDIR}/${ARCH_SUBDIR}
# long double format
.if ${LDBL_PREC} == 64
.PATH: ${.CURDIR}/ld80
CFLAGS+= -I${.CURDIR}/ld80
.elif ${LDBL_PREC} == 113
.PATH: ${.CURDIR}/ld128
CFLAGS+= -I${.CURDIR}/ld128
.endif
.PATH: ${.CURDIR}/bsdsrc
.PATH: ${.CURDIR}/src
.PATH: ${.CURDIR}/man
LIB= m
SHLIBDIR?= /lib
SHLIB_MAJOR= 5
WARNS?= 1
COMMON_SRCS= b_exp.c b_log.c b_tgamma.c \
e_acos.c e_acosf.c e_acosh.c e_acoshf.c e_asin.c e_asinf.c \
e_atan2.c e_atan2f.c e_atanh.c e_atanhf.c e_cosh.c e_coshf.c e_exp.c \
e_expf.c e_fmod.c e_fmodf.c e_gamma.c e_gamma_r.c e_gammaf.c \
e_gammaf_r.c e_hypot.c e_hypotf.c e_j0.c e_j0f.c e_j1.c e_j1f.c \
e_jn.c e_jnf.c e_lgamma.c e_lgamma_r.c e_lgammaf.c e_lgammaf_r.c \
e_log.c e_log10.c e_log10f.c e_log2.c e_log2f.c e_logf.c \
e_pow.c e_powf.c e_rem_pio2.c \
e_rem_pio2f.c e_remainder.c e_remainderf.c e_scalb.c e_scalbf.c \
e_sinh.c e_sinhf.c e_sqrt.c e_sqrtf.c fenv.c \
k_cos.c k_cosf.c k_exp.c k_expf.c k_rem_pio2.c k_sin.c k_sinf.c \
k_tan.c k_tanf.c \
s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_carg.c s_cargf.c s_cargl.c \
s_cbrt.c s_cbrtf.c s_ceil.c s_ceilf.c \
s_copysign.c s_copysignf.c s_cos.c s_cosf.c \
s_csqrt.c s_csqrtf.c s_erf.c s_erff.c \
s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c s_fabsf.c s_fdim.c \
s_finite.c s_finitef.c \
s_floor.c s_floorf.c s_fma.c s_fmaf.c \
s_fmax.c s_fmaxf.c s_fmaxl.c s_fmin.c \
s_fminf.c s_fminl.c s_frexp.c s_frexpf.c s_ilogb.c s_ilogbf.c \
s_ilogbl.c s_isfinite.c s_isnan.c s_isnormal.c \
s_llrint.c s_llrintf.c s_llround.c s_llroundf.c s_llroundl.c \
s_log1p.c s_log1pf.c s_logb.c s_logbf.c s_lrint.c s_lrintf.c \
s_lround.c s_lroundf.c s_lroundl.c s_modff.c \
s_nan.c s_nearbyint.c s_nextafter.c s_nextafterf.c \
s_nexttowardf.c s_remquo.c s_remquof.c \
s_rint.c s_rintf.c s_round.c s_roundf.c s_roundl.c \
s_scalbln.c s_scalbn.c s_scalbnf.c s_signbit.c \
s_signgam.c s_significand.c s_significandf.c s_sin.c s_sinf.c \
s_tan.c s_tanf.c s_tanh.c s_tanhf.c s_tgammaf.c s_trunc.c s_truncf.c \
w_cabs.c w_cabsf.c w_drem.c w_dremf.c
# Location of fpmath.h and _fpmath.h
LIBCDIR= ${.CURDIR}/../libc
.if exists(${LIBCDIR}/${MACHINE_ARCH})
LIBC_ARCH=${MACHINE_ARCH}
.else
LIBC_ARCH=${MACHINE_CPUARCH}
.endif
CFLAGS+= -I${.CURDIR}/src -I${LIBCDIR}/include \
-I${LIBCDIR}/${LIBC_ARCH}
SYM_MAPS+= ${.CURDIR}/Symbol.map
VERSION_DEF= ${LIBCDIR}/Versions.def
SYMBOL_MAPS= ${SYM_MAPS}
# C99 long double functions
COMMON_SRCS+= s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c
.if ${LDBL_PREC} != 53
# If long double != double use these; otherwise, we alias the double versions.
COMMON_SRCS+= e_acosl.c e_asinl.c e_atan2l.c e_fmodl.c \
e_hypotl.c e_remainderl.c e_sqrtl.c \
invtrig.c k_cosl.c k_sinl.c k_tanl.c \
s_atanl.c s_cbrtl.c s_ceill.c s_cosl.c s_cprojl.c \
s_csqrtl.c s_exp2l.c s_floorl.c s_fmal.c \
s_frexpl.c s_logbl.c s_nanl.c s_nextafterl.c s_nexttoward.c \
s_remquol.c s_rintl.c s_scalbnl.c \
s_sinl.c s_tanl.c s_truncl.c w_cabsl.c
.endif
# C99 complex functions
COMMON_SRCS+= s_ccosh.c s_ccoshf.c s_cexp.c s_cexpf.c \
s_cimag.c s_cimagf.c s_cimagl.c \
s_conj.c s_conjf.c s_conjl.c \
s_cproj.c s_cprojf.c s_creal.c s_crealf.c s_creall.c \
s_csinh.c s_csinhf.c s_ctanh.c s_ctanhf.c
# FreeBSD's C library supplies these functions:
#COMMON_SRCS+= s_fabs.c s_frexp.c s_isnan.c s_ldexp.c s_modf.c
# Exclude the generic versions of what we provide in the MD area.
.if defined(ARCH_SRCS)
.for i in ${ARCH_SRCS}
COMMON_SRCS:= ${COMMON_SRCS:N${i:R}.c}
.endfor
.endif
# Some files need certain gcc built-in functions to be disabled, since gcc's
# model of the functions bogusly assumes -fno-trapping-math.
XRINT_CFLAGS= -fno-builtin-rint -fno-builtin-rintf -fno-builtin-rintl
CFLAGS+= ${XRINT_CFLAGS}
XRINT_CFLAGS:= ${.IMPSRC:M*/s_nearbyint.c:C/^.+$/${XRINT_CFLAGS}/:C/^$//}
SRCS= ${COMMON_SRCS} ${ARCH_SRCS}
INCS= fenv.h math.h
MAN= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 \
ceil.3 ccos.3 ccosh.3 cexp.3 \
cimag.3 copysign.3 cos.3 cosh.3 csqrt.3 erf.3 exp.3 fabs.3 fdim.3 \
feclearexcept.3 feenableexcept.3 fegetenv.3 \
fegetround.3 fenv.3 floor.3 \
fma.3 fmax.3 fmod.3 hypot.3 ieee.3 ieee_test.3 ilogb.3 j0.3 \
lgamma.3 log.3 lrint.3 lround.3 math.3 nan.3 \
nextafter.3 remainder.3 rint.3 \
round.3 scalbn.3 signbit.3 sin.3 sinh.3 sqrt.3 tan.3 tanh.3 trunc.3 \
complex.3
MLINKS+=acos.3 acosf.3 acos.3 acosl.3
MLINKS+=acosh.3 acoshf.3
MLINKS+=asin.3 asinf.3 asin.3 asinl.3
MLINKS+=asinh.3 asinhf.3
MLINKS+=atan.3 atanf.3 atan.3 atanl.3
MLINKS+=atanh.3 atanhf.3
MLINKS+=atan2.3 atan2f.3 atan2.3 atan2l.3 \
atan2.3 carg.3 atan2.3 cargf.3 atan2.3 cargl.3
MLINKS+=ccos.3 ccosf.3 ccos.3 csin.3 ccos.3 csinf.3 ccos.3 ctan.3 ccos.3 ctanf.3
MLINKS+=ccosh.3 ccoshf.3 ccosh.3 csinh.3 ccosh.3 csinhf.3 \
ccosh.3 ctanh.3 ccosh.3 ctanhf.3
MLINKS+=ceil.3 ceilf.3 ceil.3 ceill.3
MLINKS+=cexp.3 cexpf.3
MLINKS+=cimag.3 cimagf.3 cimag.3 cimagl.3 \
cimag.3 conj.3 cimag.3 conjf.3 cimag.3 conjl.3 \
cimag.3 cproj.3 cimag.3 cprojf.3 cimag.3 cprojl.3 \
cimag.3 creal.3 cimag.3 crealf.3 cimag.3 creall.3
MLINKS+=copysign.3 copysignf.3 copysign.3 copysignl.3
MLINKS+=cos.3 cosf.3 cos.3 cosl.3
MLINKS+=cosh.3 coshf.3
MLINKS+=csqrt.3 csqrtf.3 csqrt.3 csqrtl.3
MLINKS+=erf.3 erfc.3 erf.3 erff.3 erf.3 erfcf.3
MLINKS+=exp.3 expm1.3 exp.3 expm1f.3 exp.3 pow.3 exp.3 powf.3 \
exp.3 exp2.3 exp.3 exp2f.3 exp.3 exp2l.3 exp.3 expf.3
MLINKS+=fabs.3 fabsf.3 fabs.3 fabsl.3
MLINKS+=fdim.3 fdimf.3 fdim.3 fdiml.3
MLINKS+=feclearexcept.3 fegetexceptflag.3 feclearexcept.3 feraiseexcept.3 \
feclearexcept.3 fesetexceptflag.3 feclearexcept.3 fetestexcept.3
MLINKS+=feenableexcept.3 fedisableexcept.3 feenableexcept.3 fegetexcept.3
MLINKS+=fegetenv.3 feholdexcept.3 fegetenv.3 fesetenv.3 \
fegetenv.3 feupdateenv.3
MLINKS+=fegetround.3 fesetround.3
MLINKS+=floor.3 floorf.3 floor.3 floorl.3
MLINKS+=fma.3 fmaf.3 fma.3 fmal.3
MLINKS+=fmax.3 fmaxf.3 fmax.3 fmaxl.3 \
fmax.3 fmin.3 fmax.3 fminf.3 fmax.3 fminl.3
MLINKS+=fmod.3 fmodf.3 fmod.3 fmodl.3
MLINKS+=hypot.3 cabs.3 hypot.3 cabsf.3 hypot.3 cabsl.3 \
hypot.3 hypotf.3 hypot.3 hypotl.3
MLINKS+=ieee_test.3 scalb.3 ieee_test.3 scalbf.3
MLINKS+=ieee_test.3 significand.3 ieee_test.3 significandf.3
MLINKS+=ilogb.3 ilogbf.3 ilogb.3 ilogbl.3 \
ilogb.3 logb.3 ilogb.3 logbf.3 ilogb.3 logbl.3
MLINKS+=j0.3 j1.3 j0.3 jn.3 j0.3 y0.3 j0.3 y1.3 j0.3 y1f.3 j0.3 yn.3
MLINKS+=j0.3 j0f.3 j0.3 j1f.3 j0.3 jnf.3 j0.3 y0f.3 j0.3 ynf.3
MLINKS+=lgamma.3 gamma.3 lgamma.3 gammaf.3 lgamma.3 lgammaf.3 \
lgamma.3 tgamma.3 lgamma.3 tgammaf.3
MLINKS+=log.3 log10.3 log.3 log10f.3 log.3 log1p.3 log.3 log1pf.3 log.3 logf.3 log.3 log2.3 log.3 log2f.3
MLINKS+=lrint.3 llrint.3 lrint.3 llrintf.3 lrint.3 llrintl.3 \
lrint.3 lrintf.3 lrint.3 lrintl.3
MLINKS+=lround.3 llround.3 lround.3 llroundf.3 lround.3 llroundl.3 \
lround.3 lroundf.3 lround.3 lroundl.3
MLINKS+=nan.3 nanf.3 nan.3 nanl.3
MLINKS+=nextafter.3 nextafterf.3 nextafter.3 nextafterl.3
MLINKS+=nextafter.3 nexttoward.3 nextafter.3 nexttowardf.3
MLINKS+=nextafter.3 nexttowardl.3
MLINKS+=remainder.3 remainderf.3 remainder.3 remainderl.3 \
remainder.3 remquo.3 remainder.3 remquof.3 remainder.3 remquol.3
MLINKS+=rint.3 rintf.3 rint.3 rintl.3 \
rint.3 nearbyint.3 rint.3 nearbyintf.3 rint.3 nearbyintl.3
MLINKS+=round.3 roundf.3 round.3 roundl.3
MLINKS+=scalbn.3 scalbln.3 scalbn.3 scalblnf.3 scalbn.3 scalblnl.3
MLINKS+=scalbn.3 scalbnf.3 scalbn.3 scalbnl.3
MLINKS+=sin.3 sinf.3 sin.3 sinl.3
MLINKS+=sinh.3 sinhf.3
MLINKS+=sqrt.3 cbrt.3 sqrt.3 cbrtf.3 sqrt.3 cbrtl.3 sqrt.3 sqrtf.3 \
sqrt.3 sqrtl.3
MLINKS+=tan.3 tanf.3 tan.3 tanl.3
MLINKS+=tanh.3 tanhf.3
MLINKS+=trunc.3 truncf.3 trunc.3 truncl.3
.include <bsd.lib.mk>

252
Symbol.map Normal file
View file

@ -0,0 +1,252 @@
/*
* $FreeBSD: src/lib/msun/Symbol.map,v 1.30 2011/10/17 05:41:03 das Exp $
*/
/* 7.0-CURRENT */
FBSD_1.0 {
__fe_dfl_env;
tgamma;
acos;
acosf;
acosh;
acoshf;
asin;
asinf;
atan2;
atan2f;
atanh;
atanhf;
cosh;
coshf;
exp;
expf;
fmod;
fmodf;
gamma;
gamma_r;
gammaf;
gammaf_r;
hypot;
hypotf;
j0;
y0;
j0f;
y0f;
j1;
y1;
j1f;
y1f;
jn;
yn;
jnf;
ynf;
lgamma;
lgamma_r;
lgammaf;
lgammaf_r;
log;
log10;
log10f;
logf;
pow;
powf;
remainder;
remainderf;
scalb;
scalbf;
sinh;
sinhf;
sqrt;
sqrtf;
asinh;
asinhf;
atan;
atanf;
cbrt;
cbrtf;
ceil;
ceilf;
ceill;
cimag;
cimagf;
cimagl;
conj;
conjf;
conjl;
copysign;
copysignf;
copysignl;
cos;
cosf;
creal;
crealf;
creall;
erf;
erfc;
erff;
erfcf;
exp2;
exp2f;
expm1;
expm1f;
fabs;
fabsf;
fabsl;
fdim;
fdimf;
fdiml;
finite;
finitef;
floor;
floorf;
floorl;
fma;
fmaf;
fmal;
fmax;
fmaxf;
fmaxl;
fmin;
fminf;
fminl;
frexp;
frexpf;
frexpl;
ilogb;
ilogbf;
ilogbl;
__isfinite;
__isfinitef;
__isfinitel;
isnanf;
__isnanl;
__isnormal;
__isnormalf;
__isnormall;
llrint;
llrintf;
llround;
llroundf;
llroundl;
log1p;
log1pf;
logb;
logbf;
lrint;
lrintf;
lround;
lroundf;
lroundl;
modff;
modfl;
nearbyint;
nearbyintf;
nextafter;
nexttoward;
nexttowardl;
nextafterl;
nextafterf;
nexttowardf;
remquo;
remquof;
rint;
rintf;
round;
roundf;
roundl;
scalbln;
scalblnf;
scalblnl;
scalbn;
scalbnl;
scalbnf;
ldexpf;
ldexpl;
__signbit;
__signbitf;
__signbitl;
signgam;
significand;
significandf;
sin;
sinf;
tan;
tanf;
tanh;
tanhf;
trunc;
truncf;
truncl;
cabs;
cabsf;
drem;
dremf;
};
/* First added in 8.0-CURRENT */
FBSD_1.1 {
carg;
cargf;
csqrt;
csqrtf;
logbl;
nan;
nanf;
nanl;
llrintl;
lrintl;
nearbyintl;
rintl;
exp2l;
sinl;
cosl;
tanl;
tgammaf;
sqrtl;
hypotl;
cabsl;
csqrtl;
remquol;
remainderl;
fmodl;
acosl;
asinl;
atan2l;
atanl;
cargl;
cproj;
cprojf;
cprojl;
};
/* First added in 9.0-CURRENT */
FBSD_1.2 {
__isnanf;
cbrtl;
cexp;
cexpf;
log2;
log2f;
};
/* First added in 10.0-CURRENT */
FBSD_1.3 {
feclearexcept;
fegetexceptflag;
fetestexcept;
fegetround;
fesetround;
fesetenv;
csin;
csinf;
csinh;
csinhf;
ccos;
ccosf;
ccosh;
ccoshf;
ctan;
ctanf;
ctanh;
ctanhf;
};

View file

@ -1,24 +0,0 @@
Makefile.inc
Symbol.map
e_remainder.S
e_remainderf.S
e_remainderl.S
e_sqrt.S
e_sqrtf.S
e_sqrtl.S
fenv.c
fenv.h
s_llrint.S
s_llrintf.S
s_llrintl.S
s_logbl.S
s_lrint.S
s_lrintf.S
s_lrintl.S
s_remquo.S
s_remquof.S
s_remquol.S
s_rintl.S
s_scalbn.S
s_scalbnf.S
s_scalbnl.S

View file

@ -1,5 +1,5 @@
/*
* $FreeBSD: src/lib/msun/amd64/Symbol.map,v 1.2 2007/04/29 14:05:21 deischen Exp $
* $FreeBSD: src/lib/msun/amd64/Symbol.map,v 1.3 2011/10/10 15:43:09 das Exp $
*/
FBSD_1.0 {
fesetexceptflag;
@ -7,8 +7,6 @@ FBSD_1.0 {
fegetenv;
feholdexcept;
feupdateenv;
__feenableexcept;
__fedisableexcept;
feenableexcept;
fedisableexcept;
};

View file

@ -23,13 +23,19 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/amd64/fenv.c,v 1.5 2010/02/03 20:23:47 kib Exp $
* $FreeBSD: src/lib/msun/amd64/fenv.c,v 1.8 2011/10/21 06:25:31 das Exp $
*/
#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/fpu.h>
#include <fenv.h>
#define __fenv_static
#include "fenv.h"
#ifdef __GNUC_GNU_INLINE__
#error "This file must be compiled with C99 'inline' semantics"
#endif
const fenv_t __fe_dfl_env = {
{ 0xffff0000 | __INITIAL_FPUCW__,
@ -41,6 +47,9 @@ const fenv_t __fe_dfl_env = {
__INITIAL_MXCSR__
};
extern inline int feclearexcept(int __excepts);
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
int
fesetexceptflag(const fexcept_t *flagp, int excepts)
{
@ -69,6 +78,10 @@ feraiseexcept(int excepts)
return (0);
}
extern inline int fetestexcept(int __excepts);
extern inline int fegetround(void);
extern inline int fesetround(int __round);
int
fegetenv(fenv_t *envp)
{
@ -98,6 +111,8 @@ feholdexcept(fenv_t *envp)
return (0);
}
extern inline int fesetenv(const fenv_t *__envp);
int
feupdateenv(const fenv_t *envp)
{
@ -120,12 +135,12 @@ __feenableexcept(int mask)
mask &= FE_ALL_EXCEPT;
__fnstcw(&control);
__stmxcsr(&mxcsr);
omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
omask = ~(control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
control &= ~mask;
__fldcw(control);
mxcsr &= ~(mask << _SSE_EMASK_SHIFT);
__ldmxcsr(mxcsr);
return (~omask);
return (omask);
}
int
@ -137,12 +152,12 @@ __fedisableexcept(int mask)
mask &= FE_ALL_EXCEPT;
__fnstcw(&control);
__stmxcsr(&mxcsr);
omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
omask = ~(control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
control |= mask;
__fldcw(control);
mxcsr |= mask << _SSE_EMASK_SHIFT;
__ldmxcsr(mxcsr);
return (~omask);
return (omask);
}
__weak_reference(__feenableexcept, feenableexcept);

View file

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/amd64/fenv.h,v 1.7 2010/02/03 20:23:47 kib Exp $
* $FreeBSD: src/lib/msun/amd64/fenv.h,v 1.8 2011/10/10 15:43:09 das Exp $
*/
#ifndef _FENV_H_
@ -32,6 +32,10 @@
#include <sys/cdefs.h>
#include <sys/_types.h>
#ifndef __fenv_static
#define __fenv_static static
#endif
typedef struct {
struct {
__uint32_t __control;
@ -89,7 +93,7 @@ extern const fenv_t __fe_dfl_env;
#define __ldmxcsr(__csr) __asm __volatile("ldmxcsr %0" : : "m" (__csr))
#define __stmxcsr(__csr) __asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
static __inline int
__fenv_static inline int
feclearexcept(int __excepts)
{
fenv_t __env;
@ -107,7 +111,7 @@ feclearexcept(int __excepts)
return (0);
}
static __inline int
__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
__uint32_t __mxcsr;
@ -122,7 +126,7 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
int feraiseexcept(int __excepts);
static __inline int
__fenv_static inline int
fetestexcept(int __excepts)
{
__uint32_t __mxcsr;
@ -133,7 +137,7 @@ fetestexcept(int __excepts)
return ((__status | __mxcsr) & __excepts);
}
static __inline int
__fenv_static inline int
fegetround(void)
{
__uint16_t __control;
@ -148,7 +152,7 @@ fegetround(void)
return (__control & _ROUND_MASK);
}
static __inline int
__fenv_static inline int
fesetround(int __round)
{
__uint32_t __mxcsr;
@ -173,7 +177,7 @@ fesetround(int __round)
int fegetenv(fenv_t *__envp);
int feholdexcept(fenv_t *__envp);
static __inline int
__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
@ -197,7 +201,8 @@ int feupdateenv(const fenv_t *__envp);
int feenableexcept(int __mask);
int fedisableexcept(int __mask);
static __inline int
/* We currently provide no external definition of fegetexcept(). */
static inline int
fegetexcept(void)
{
__uint16_t __control;

4
arm/Makefile.inc Normal file
View file

@ -0,0 +1,4 @@
# $FreeBSD: src/lib/msun/arm/Makefile.inc,v 1.2 2006/03/27 23:59:44 deischen Exp $
LDBL_PREC = 53
SYM_MAPS += ${.CURDIR}/arm/Symbol.map

13
arm/Symbol.map Normal file
View file

@ -0,0 +1,13 @@
/*
* $FreeBSD: src/lib/msun/arm/Symbol.map,v 1.3 2011/10/10 15:43:09 das Exp $
*/
FBSD_1.0 {
};
FBSD_1.3 {
fesetexceptflag;
feraiseexcept;
fegetenv;
feholdexcept;
feupdateenv;
};

52
arm/fenv.c Normal file
View file

@ -0,0 +1,52 @@
/*-
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/arm/fenv.c,v 1.3 2011/10/16 05:37:56 das Exp $
*/
#define __fenv_static
#include "fenv.h"
#ifdef __GNUC_GNU_INLINE__
#error "This file must be compiled with C99 'inline' semantics"
#endif
/*
* Hopefully the system ID byte is immutable, so it's valid to use
* this as a default environment.
*/
const fenv_t __fe_dfl_env = 0;
extern inline int feclearexcept(int __excepts);
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
extern inline int feraiseexcept(int __excepts);
extern inline int fetestexcept(int __excepts);
extern inline int fegetround(void);
extern inline int fesetround(int __round);
extern inline int fegetenv(fenv_t *__envp);
extern inline int feholdexcept(fenv_t *__envp);
extern inline int fesetenv(const fenv_t *__envp);
extern inline int feupdateenv(const fenv_t *__envp);

223
arm/fenv.h Normal file
View file

@ -0,0 +1,223 @@
/*-
* Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/arm/fenv.h,v 1.6 2011/10/10 15:43:09 das Exp $
*/
#ifndef _FENV_H_
#define _FENV_H_
#include <sys/_types.h>
#ifndef __fenv_static
#define __fenv_static static
#endif
typedef __uint32_t fenv_t;
typedef __uint32_t fexcept_t;
/* Exception flags */
#define FE_INVALID 0x0001
#define FE_DIVBYZERO 0x0002
#define FE_OVERFLOW 0x0004
#define FE_UNDERFLOW 0x0008
#define FE_INEXACT 0x0010
#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
/* Rounding modes */
#define FE_TONEAREST 0x0000
#define FE_TOWARDZERO 0x0001
#define FE_UPWARD 0x0002
#define FE_DOWNWARD 0x0003
#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
FE_UPWARD | FE_TOWARDZERO)
__BEGIN_DECLS
/* Default floating-point environment */
extern const fenv_t __fe_dfl_env;
#define FE_DFL_ENV (&__fe_dfl_env)
/* We need to be able to map status flag positions to mask flag positions */
#define _FPUSW_SHIFT 16
#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)
#ifdef ARM_HARD_FLOAT
#define __rfs(__fpsr) __asm __volatile("rfs %0" : "=r" (*(__fpsr)))
#define __wfs(__fpsr) __asm __volatile("wfs %0" : : "r" (__fpsr))
#else
#define __rfs(__fpsr)
#define __wfs(__fpsr)
#endif
__fenv_static inline int
feclearexcept(int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
__fpsr &= ~__excepts;
__wfs(__fpsr);
return (0);
}
__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
*__flagp = __fpsr & __excepts;
return (0);
}
__fenv_static inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
__fpsr &= ~__excepts;
__fpsr |= *__flagp & __excepts;
__wfs(__fpsr);
return (0);
}
__fenv_static inline int
feraiseexcept(int __excepts)
{
fexcept_t __ex = __excepts;
fesetexceptflag(&__ex, __excepts); /* XXX */
return (0);
}
__fenv_static inline int
fetestexcept(int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
return (__fpsr & __excepts);
}
__fenv_static inline int
fegetround(void)
{
/*
* Apparently, the rounding mode is specified as part of the
* instruction format on ARM, so the dynamic rounding mode is
* indeterminate. Some FPUs may differ.
*/
return (-1);
}
__fenv_static inline int
fesetround(int __round)
{
return (-1);
}
__fenv_static inline int
fegetenv(fenv_t *__envp)
{
__rfs(__envp);
return (0);
}
__fenv_static inline int
feholdexcept(fenv_t *__envp)
{
fenv_t __env;
__rfs(&__env);
*__envp = __env;
__env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
__wfs(__env);
return (0);
}
__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
__wfs(*__envp);
return (0);
}
__fenv_static inline int
feupdateenv(const fenv_t *__envp)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
__wfs(*__envp);
feraiseexcept(__fpsr & FE_ALL_EXCEPT);
return (0);
}
#if __BSD_VISIBLE
/* We currently provide no external definitions of the functions below. */
static inline int
feenableexcept(int __mask)
{
fenv_t __old_fpsr, __new_fpsr;
__rfs(&__old_fpsr);
__new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT;
__wfs(__new_fpsr);
return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
static inline int
fedisableexcept(int __mask)
{
fenv_t __old_fpsr, __new_fpsr;
__rfs(&__old_fpsr);
__new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
__wfs(__new_fpsr);
return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
static inline int
fegetexcept(void)
{
fenv_t __fpsr;
__rfs(&__fpsr);
return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
}
#endif /* __BSD_VISIBLE */
__END_DECLS
#endif /* !_FENV_H_ */

View file

@ -1,4 +0,0 @@
b_exp.c
b_log.c
b_tgamma.c
mathimpl.h

View file

@ -33,7 +33,7 @@
/* @(#)exp.c 8.1 (Berkeley) 6/4/93 */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_exp.c,v 1.8 2008/02/22 02:26:51 das Exp $");
__FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_exp.c,v 1.9 2011/10/16 05:37:20 das Exp $");
/* EXP(X)
@ -74,16 +74,16 @@ __FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_exp.c,v 1.8 2008/02/22 02:26:51 das Ex
#include "mathimpl.h"
const static double p1 = 0x1.555555555553ep-3;
const static double p2 = -0x1.6c16c16bebd93p-9;
const static double p3 = 0x1.1566aaf25de2cp-14;
const static double p4 = -0x1.bbd41c5d26bf1p-20;
const static double p5 = 0x1.6376972bea4d0p-25;
const static double ln2hi = 0x1.62e42fee00000p-1;
const static double ln2lo = 0x1.a39ef35793c76p-33;
const static double lnhuge = 0x1.6602b15b7ecf2p9;
const static double lntiny = -0x1.77af8ebeae354p9;
const static double invln2 = 0x1.71547652b82fep0;
static const double p1 = 0x1.555555555553ep-3;
static const double p2 = -0x1.6c16c16bebd93p-9;
static const double p3 = 0x1.1566aaf25de2cp-14;
static const double p4 = -0x1.bbd41c5d26bf1p-20;
static const double p5 = 0x1.6376972bea4d0p-25;
static const double ln2hi = 0x1.62e42fee00000p-1;
static const double ln2lo = 0x1.a39ef35793c76p-33;
static const double lnhuge = 0x1.6602b15b7ecf2p9;
static const double lntiny = -0x1.77af8ebeae354p9;
static const double invln2 = 0x1.71547652b82fep0;
#if 0
double exp(x)

View file

@ -1,53 +0,0 @@
Makefile.inc
Symbol.map
e_exp.S
e_fmod.S
e_log.S
e_log10.S
e_log10f.S
e_logf.S
e_remainder.S
e_remainderf.S
e_remainderl.S
e_sqrt.S
e_sqrtf.S
e_sqrtl.S
fenv.c
fenv.h
invtrig.c
s_ceil.S
s_ceilf.S
s_ceill.S
s_copysign.S
s_copysignf.S
s_copysignl.S
s_cos.S
s_finite.S
s_floor.S
s_floorf.S
s_floorl.S
s_llrint.S
s_llrintf.S
s_llrintl.S
s_logb.S
s_logbf.S
s_logbl.S
s_lrint.S
s_lrintf.S
s_lrintl.S
s_remquo.S
s_remquof.S
s_remquol.S
s_rint.S
s_rintf.S
s_rintl.S
s_scalbn.S
s_scalbnf.S
s_scalbnl.S
s_significand.S
s_significandf.S
s_sin.S
s_tan.S
s_trunc.S
s_truncf.S
s_truncl.S

View file

@ -1,5 +1,5 @@
/*
* $FreeBSD: src/lib/msun/i387/Symbol.map,v 1.2 2007/04/29 14:05:21 deischen Exp $
* $FreeBSD: src/lib/msun/i387/Symbol.map,v 1.3 2011/10/10 15:43:09 das Exp $
*/
FBSD_1.0 {
__has_sse;
@ -9,8 +9,6 @@ FBSD_1.0 {
fegetenv;
feholdexcept;
feupdateenv;
__feenableexcept;
__fedisableexcept;
feenableexcept;
fedisableexcept;
};

View file

@ -23,14 +23,20 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/i387/fenv.c,v 1.4 2010/02/03 20:23:47 kib Exp $
* $FreeBSD: src/lib/msun/i387/fenv.c,v 1.8 2011/10/21 06:25:31 das Exp $
*/
#include <sys/cdefs.h>
#include <sys/types.h>
#include <machine/npx.h>
#define __fenv_static
#include "fenv.h"
#ifdef __GNUC_GNU_INLINE__
#error "This file must be compiled with C99 'inline' semantics"
#endif
const fenv_t __fe_dfl_env = {
__INITIAL_NPXCW__,
0x0000,
@ -83,6 +89,9 @@ __test_sse(void)
return (0);
}
extern inline int feclearexcept(int __excepts);
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
int
fesetexceptflag(const fexcept_t *flagp, int excepts)
{
@ -114,6 +123,10 @@ feraiseexcept(int excepts)
return (0);
}
extern inline int fetestexcept(int __excepts);
extern inline int fegetround(void);
extern inline int fesetround(int __round);
int
fegetenv(fenv_t *envp)
{
@ -149,6 +162,8 @@ feholdexcept(fenv_t *envp)
return (0);
}
extern inline int fesetenv(const fenv_t *__envp);
int
feupdateenv(const fenv_t *envp)
{
@ -177,14 +192,14 @@ __feenableexcept(int mask)
__stmxcsr(&mxcsr);
else
mxcsr = 0;
omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
omask = ~(control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
control &= ~mask;
__fldcw(control);
if (__HAS_SSE()) {
mxcsr &= ~(mask << _SSE_EMASK_SHIFT);
__ldmxcsr(mxcsr);
}
return (~omask);
return (omask);
}
int
@ -199,14 +214,14 @@ __fedisableexcept(int mask)
__stmxcsr(&mxcsr);
else
mxcsr = 0;
omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
omask = ~(control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
control |= mask;
__fldcw(control);
if (__HAS_SSE()) {
mxcsr |= mask << _SSE_EMASK_SHIFT;
__ldmxcsr(mxcsr);
}
return (~omask);
return (omask);
}
__weak_reference(__feenableexcept, feenableexcept);

View file

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/i387/fenv.h,v 1.7 2010/02/03 20:23:47 kib Exp $
* $FreeBSD: src/lib/msun/i387/fenv.h,v 1.8 2011/10/10 15:43:09 das Exp $
*/
#ifndef _FENV_H_
@ -32,6 +32,10 @@
#include <sys/cdefs.h>
#include <sys/_types.h>
#ifndef __fenv_static
#define __fenv_static static
#endif
/*
* To preserve binary compatibility with FreeBSD 5.3, we pack the
* mxcsr into some reserved fields, rather than changing sizeof(fenv_t).
@ -110,7 +114,7 @@ extern const fenv_t __fe_dfl_env;
#define __ldmxcsr(__csr) __asm __volatile("ldmxcsr %0" : : "m" (__csr))
#define __stmxcsr(__csr) __asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
static __inline int
__fenv_static inline int
feclearexcept(int __excepts)
{
fenv_t __env;
@ -131,7 +135,7 @@ feclearexcept(int __excepts)
return (0);
}
static __inline int
__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
__uint32_t __mxcsr;
@ -149,7 +153,7 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
int feraiseexcept(int __excepts);
static __inline int
__fenv_static inline int
fetestexcept(int __excepts)
{
__uint32_t __mxcsr;
@ -163,7 +167,7 @@ fetestexcept(int __excepts)
return ((__status | __mxcsr) & __excepts);
}
static __inline int
__fenv_static inline int
fegetround(void)
{
__uint16_t __control;
@ -178,7 +182,7 @@ fegetround(void)
return (__control & _ROUND_MASK);
}
static __inline int
__fenv_static inline int
fesetround(int __round)
{
__uint32_t __mxcsr;
@ -205,7 +209,7 @@ fesetround(int __round)
int fegetenv(fenv_t *__envp);
int feholdexcept(fenv_t *__envp);
static __inline int
__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
fenv_t __env = *__envp;
@ -234,7 +238,8 @@ int feupdateenv(const fenv_t *__envp);
int feenableexcept(int __mask);
int fedisableexcept(int __mask);
static __inline int
/* We currently provide no external definition of fegetexcept(). */
static inline int
fegetexcept(void)
{
__uint16_t __control;

5
ia64/Makefile.inc Normal file
View file

@ -0,0 +1,5 @@
# $FreeBSD: src/lib/msun/ia64/Makefile.inc,v 1.3 2006/03/27 23:59:45 deischen Exp $
ARCH_SRCS = s_fma.S s_fmaf.S s_fmal.S
LDBL_PREC = 64
SYM_MAPS += ${.CURDIR}/ia64/Symbol.map

13
ia64/Symbol.map Normal file
View file

@ -0,0 +1,13 @@
/*
* $FreeBSD: src/lib/msun/ia64/Symbol.map,v 1.3 2011/10/10 15:43:09 das Exp $
*/
FBSD_1.0 {
feupdateenv;
};
FBSD_1.3 {
fesetexceptflag;
feraiseexcept;
fegetenv;
feholdexcept;
};

66
ia64/fenv.c Normal file
View file

@ -0,0 +1,66 @@
/*-
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/ia64/fenv.c,v 1.4 2011/10/16 05:37:56 das Exp $
*/
#include <sys/types.h>
#define __fenv_static
#include "fenv.h"
#ifdef __GNUC_GNU_INLINE__
#error "This file must be compiled with C99 'inline' semantics"
#endif
const fenv_t __fe_dfl_env = 0x0009804c8a70033fULL;
extern inline int feclearexcept(int __excepts);
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
extern inline int feraiseexcept(int __excepts);
extern inline int fetestexcept(int __excepts);
extern inline int fegetround(void);
extern inline int fesetround(int __round);
extern inline int fegetenv(fenv_t *__envp);
extern inline int feholdexcept(fenv_t *__envp);
extern inline int fesetenv(const fenv_t *__envp);
/*
* It doesn't pay to inline feupdateenv() because it includes one of
* the rare uses of feraiseexcept() where the argument is not a
* constant. Thus, no dead code elimination can occur, resulting in
* significant bloat.
*/
int
feupdateenv(const fenv_t *envp)
{
fenv_t fpsr;
__stfpsr(&fpsr);
__ldfpsr(*envp);
feraiseexcept((fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
return (0);
}

248
ia64/fenv.h Normal file
View file

@ -0,0 +1,248 @@
/*-
* Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/ia64/fenv.h,v 1.5 2011/10/10 15:43:09 das Exp $
*/
#ifndef _FENV_H_
#define _FENV_H_
#include <sys/_types.h>
#ifndef __fenv_static
#define __fenv_static static
#endif
typedef __uint64_t fenv_t;
typedef __uint16_t fexcept_t;
/* Exception flags */
#define FE_INVALID 0x01
#define FE_DENORMAL 0x02
#define FE_DIVBYZERO 0x04
#define FE_OVERFLOW 0x08
#define FE_UNDERFLOW 0x10
#define FE_INEXACT 0x20
#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_DENORMAL | FE_INEXACT | \
FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
/* Rounding modes */
#define FE_TONEAREST 0x0000
#define FE_DOWNWARD 0x0400
#define FE_UPWARD 0x0800
#define FE_TOWARDZERO 0x0c00
#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
FE_UPWARD | FE_TOWARDZERO)
__BEGIN_DECLS
/* Default floating-point environment */
extern const fenv_t __fe_dfl_env;
#define FE_DFL_ENV (&__fe_dfl_env)
#define _FPUSW_SHIFT 13
#define __stfpsr(__r) __asm __volatile("mov %0=ar.fpsr" : "=r" (*(__r)))
#define __ldfpsr(__r) __asm __volatile("mov ar.fpsr=%0;;" : : "r" (__r))
__fenv_static inline int
feclearexcept(int __excepts)
{
fenv_t __fpsr;
__stfpsr(&__fpsr);
__fpsr &= ~((fenv_t)__excepts << _FPUSW_SHIFT);
__ldfpsr(__fpsr);
return (0);
}
__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
fenv_t __fpsr;
__stfpsr(&__fpsr);
*__flagp = (fexcept_t)(__fpsr >> _FPUSW_SHIFT) & __excepts;
return (0);
}
__fenv_static inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
fenv_t __fpsr;
__stfpsr(&__fpsr);
__fpsr &= ~((fenv_t)__excepts << _FPUSW_SHIFT);
__fpsr |= (fenv_t)(__excepts & *__flagp) << _FPUSW_SHIFT;
__ldfpsr(__fpsr);
return (0);
}
/*
* It is worthwhile to use the inline version of this function iff it
* is called with arguments that are compile-time constants (due to
* dead code elimination). Unfortunately, gcc isn't smart enough to
* figure this out automatically, and there's no way to tell it.
* We assume that constant arguments will be the common case.
*/
__fenv_static inline int
feraiseexcept(int __excepts)
{
volatile double d;
/*
* With a compiler that supports the FENV_ACCESS pragma
* properly, simple expressions like '0.0 / 0.0' should
* be sufficient to generate traps. Unfortunately, we
* need to bring a volatile variable into the equation
* to prevent incorrect optimizations.
*/
if (__excepts & FE_INVALID) {
d = 0.0;
d = 0.0 / d;
}
if (__excepts & FE_DIVBYZERO) {
d = 0.0;
d = 1.0 / d;
}
if (__excepts & FE_OVERFLOW) {
d = 0x1.ffp1023;
d *= 2.0;
}
if (__excepts & FE_UNDERFLOW) {
d = 0x1p-1022;
d /= 0x1p1023;
}
if (__excepts & FE_INEXACT) {
d = 0x1p-1022;
d += 1.0;
}
return (0);
}
__fenv_static inline int
fetestexcept(int __excepts)
{
fenv_t __fpsr;
__stfpsr(&__fpsr);
return ((__fpsr >> _FPUSW_SHIFT) & __excepts);
}
__fenv_static inline int
fegetround(void)
{
fenv_t __fpsr;
__stfpsr(&__fpsr);
return (__fpsr & _ROUND_MASK);
}
__fenv_static inline int
fesetround(int __round)
{
fenv_t __fpsr;
if (__round & ~_ROUND_MASK)
return (-1);
__stfpsr(&__fpsr);
__fpsr &= ~_ROUND_MASK;
__fpsr |= __round;
__ldfpsr(__fpsr);
return (0);
}
__fenv_static inline int
fegetenv(fenv_t *__envp)
{
__stfpsr(__envp);
return (0);
}
__fenv_static inline int
feholdexcept(fenv_t *__envp)
{
fenv_t __fpsr;
__stfpsr(&__fpsr);
*__envp = __fpsr;
__fpsr &= ~((fenv_t)FE_ALL_EXCEPT << _FPUSW_SHIFT);
__fpsr |= FE_ALL_EXCEPT;
__ldfpsr(__fpsr);
return (0);
}
__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
__ldfpsr(*__envp);
return (0);
}
int feupdateenv(const fenv_t *__envp);
#if __BSD_VISIBLE
/* We currently provide no external definitions of the functions below. */
static inline int
feenableexcept(int __mask)
{
fenv_t __newfpsr, __oldfpsr;
__stfpsr(&__oldfpsr);
__newfpsr = __oldfpsr & ~(__mask & FE_ALL_EXCEPT);
__ldfpsr(__newfpsr);
return (~__oldfpsr & FE_ALL_EXCEPT);
}
static inline int
fedisableexcept(int __mask)
{
fenv_t __newfpsr, __oldfpsr;
__stfpsr(&__oldfpsr);
__newfpsr = __oldfpsr | (__mask & FE_ALL_EXCEPT);
__ldfpsr(__newfpsr);
return (~__oldfpsr & FE_ALL_EXCEPT);
}
static inline int
fegetexcept(void)
{
fenv_t __fpsr;
__stfpsr(&__fpsr);
return (~__fpsr & FE_ALL_EXCEPT);
}
#endif /* __BSD_VISIBLE */
__END_DECLS
#endif /* !_FENV_H_ */

35
ia64/s_fma.S Normal file
View file

@ -0,0 +1,35 @@
/*-
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD: src/lib/msun/ia64/s_fma.S,v 1.2 2009/05/25 14:37:10 attilio Exp $")
ENTRY(fma, 3)
{
fma.d f8 = f8, f9, f10
br.ret.sptk b0
}
END(fma)

35
ia64/s_fmaf.S Normal file
View file

@ -0,0 +1,35 @@
/*-
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD: src/lib/msun/ia64/s_fmaf.S,v 1.2 2009/05/25 14:37:10 attilio Exp $")
ENTRY(fmaf, 3)
{
fma.s f8 = f8, f9, f10
br.ret.sptk b0
}
END(fmaf)

35
ia64/s_fmal.S Normal file
View file

@ -0,0 +1,35 @@
/*-
* Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD: src/lib/msun/ia64/s_fmal.S,v 1.2 2009/05/25 14:37:10 attilio Exp $")
ENTRY(fmal, 3)
{
fma f8 = f8, f9, f10
br.ret.sptk b0
}
END(fmal)

View file

@ -14,7 +14,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld128/e_rem_pio2l.h,v 1.2 2011/05/30 19:41:28 kargl Exp $");
/* ld128 version of __ieee754_rem_pio2l(x,y)
*
@ -24,7 +24,7 @@
#include <float.h>
#include "openlibm.h"
#include "math.h"
#include "math_private.h"
#include "fpmath.h"

View file

@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld128/invtrig.c,v 1.1 2008/07/31 22:41:26 das Exp $");
#include "invtrig.h"

View file

@ -12,7 +12,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld128/k_cosl.c,v 1.1 2008/02/17 07:32:31 das Exp $");
/*
* ld128 version of k_cos.c. See ../src/k_cos.c for most comments.

View file

@ -12,7 +12,7 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld128/k_sinl.c,v 1.1 2008/02/17 07:32:31 das Exp $");
/*
* ld128 version of k_sin.c. See ../src/k_sin.c for most comments.

View file

@ -12,13 +12,13 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld128/k_tanl.c,v 1.1 2008/02/17 07:32:31 das Exp $");
/*
* ld128 version of k_tan.c. See ../src/k_tan.c for most comments.
*/
#include "openlibm.h"
#include "math.h"
#include "math_private.h"
/*

View file

@ -25,13 +25,13 @@
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld128/s_exp2l.c,v 1.3 2008/02/13 10:44:44 bde Exp $");
#include <float.h>
#include <stdint.h>
#include "fpmath.h"
#include "openlibm.h"
#include "math.h"
#define TBLBITS 7
#define TBLSIZE (1 << TBLBITS)

View file

@ -26,7 +26,7 @@
* $FreeBSD: src/lib/msun/ld128/s_nanl.c,v 1.3 2008/03/02 20:16:55 das Exp $
*/
#include "openlibm.h"
#include <math.h>
#include "fpmath.h"
#include "../src/math_private.h"

149
ld80/e_rem_pio2l.h Normal file
View file

@ -0,0 +1,149 @@
/* From: @(#)e_rem_pio2.c 1.4 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*
* Optimized by Bruce D. Evans.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld80/e_rem_pio2l.h,v 1.3 2011/06/18 13:56:33 benl Exp $");
/* ld80 version of __ieee754_rem_pio2l(x,y)
*
* return the remainder of x rem pi/2 in y[0]+y[1]
* use __kernel_rem_pio2()
*/
#include <float.h>
#include "math.h"
#include "math_private.h"
#include "fpmath.h"
#define BIAS (LDBL_MAX_EXP - 1)
/*
* invpio2: 64 bits of 2/pi
* pio2_1: first 39 bits of pi/2
* pio2_1t: pi/2 - pio2_1
* pio2_2: second 39 bits of pi/2
* pio2_2t: pi/2 - (pio2_1+pio2_2)
* pio2_3: third 39 bits of pi/2
* pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
*/
static const double
zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
pio2_1 = 1.57079632679597125389e+00, /* 0x3FF921FB, 0x54444000 */
pio2_2 = -1.07463465549783099519e-12, /* -0x12e7b967674000.0p-92 */
pio2_3 = 6.36831716351370313614e-25; /* 0x18a2e037074000.0p-133 */
#if defined(__amd64__) || defined(__i386__)
/* Long double constants are slow on these arches, and broken on i386. */
static const volatile double
invpio2hi = 6.3661977236758138e-01, /* 0x145f306dc9c883.0p-53 */
invpio2lo = -3.9356538861223811e-17, /* -0x16b00000000000.0p-107 */
pio2_1thi = -1.0746346554971943e-12, /* -0x12e7b9676733af.0p-92 */
pio2_1tlo = 8.8451028997905949e-29, /* 0x1c080000000000.0p-146 */
pio2_2thi = 6.3683171635109499e-25, /* 0x18a2e03707344a.0p-133 */
pio2_2tlo = 2.3183081793789774e-41, /* 0x10280000000000.0p-187 */
pio2_3thi = -2.7529965190440717e-37, /* -0x176b7ed8fbbacc.0p-174 */
pio2_3tlo = -4.2006647512740502e-54; /* -0x19c00000000000.0p-230 */
#define invpio2 ((long double)invpio2hi + invpio2lo)
#define pio2_1t ((long double)pio2_1thi + pio2_1tlo)
#define pio2_2t ((long double)pio2_2thi + pio2_2tlo)
#define pio2_3t ((long double)pio2_3thi + pio2_3tlo)
#else
static const long double
invpio2 = 6.36619772367581343076e-01L, /* 0xa2f9836e4e44152a.0p-64 */
pio2_1t = -1.07463465549719416346e-12L, /* -0x973dcb3b399d747f.0p-103 */
pio2_2t = 6.36831716351095013979e-25L, /* 0xc51701b839a25205.0p-144 */
pio2_3t = -2.75299651904407171810e-37L; /* -0xbb5bf6c7ddd660ce.0p-185 */
#endif
static inline __always_inline int
__ieee754_rem_pio2l(long double x, long double *y)
{
union IEEEl2bits u,u1;
long double z,w,t,r,fn;
double tx[3],ty[2];
int e0,ex,i,j,nx,n;
int16_t expsign;
u.e = x;
expsign = u.xbits.expsign;
ex = expsign & 0x7fff;
if (ex < BIAS + 25 || (ex == BIAS + 25 && u.bits.manh < 0xc90fdaa2)) {
/* |x| ~< 2^25*(pi/2), medium size */
/* Use a specialized rint() to get fn. Assume round-to-nearest. */
fn = x*invpio2+0x1.8p63;
fn = fn-0x1.8p63;
#ifdef HAVE_EFFICIENT_IRINT
n = irint(fn);
#else
n = fn;
#endif
r = x-fn*pio2_1;
w = fn*pio2_1t; /* 1st round good to 102 bit */
{
union IEEEl2bits u2;
int ex1;
j = ex;
y[0] = r-w;
u2.e = y[0];
ex1 = u2.xbits.expsign & 0x7fff;
i = j-ex1;
if(i>22) { /* 2nd iteration needed, good to 141 */
t = r;
w = fn*pio2_2;
r = t-w;
w = fn*pio2_2t-((t-r)-w);
y[0] = r-w;
u2.e = y[0];
ex1 = u2.xbits.expsign & 0x7fff;
i = j-ex1;
if(i>61) { /* 3rd iteration need, 180 bits acc */
t = r; /* will cover all possible cases */
w = fn*pio2_3;
r = t-w;
w = fn*pio2_3t-((t-r)-w);
y[0] = r-w;
}
}
}
y[1] = (r-y[0])-w;
return n;
}
/*
* all other (large) arguments
*/
if(ex==0x7fff) { /* x is inf or NaN */
y[0]=y[1]=x-x; return 0;
}
/* set z = scalbn(|x|,ilogb(x)-23) */
u1.e = x;
e0 = ex - BIAS - 23; /* e0 = ilogb(|x|)-23; */
u1.xbits.expsign = ex - e0;
z = u1.e;
for(i=0;i<2;i++) {
tx[i] = (double)((int32_t)(z));
z = (z-tx[i])*two24;
}
tx[2] = z;
nx = 3;
while(tx[nx-1]==zero) nx--; /* skip zero term */
n = __kernel_rem_pio2(tx,ty,e0,nx,2);
r = (long double)ty[0] + ty[1];
w = ty[1] - (r - ty[0]);
if(expsign<0) {y[0] = -r; y[1] = -w; return -n;}
y[0] = r; y[1] = w; return n;
}

82
ld80/invtrig.c Normal file
View file

@ -0,0 +1,82 @@
/*-
* Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld80/invtrig.c,v 1.1 2008/07/31 22:41:26 das Exp $");
#include "invtrig.h"
/*
* asinl() and acosl()
*/
const long double
pS0 = 1.66666666666666666631e-01L,
pS1 = -4.16313987993683104320e-01L,
pS2 = 3.69068046323246813704e-01L,
pS3 = -1.36213932016738603108e-01L,
pS4 = 1.78324189708471965733e-02L,
pS5 = -2.19216428382605211588e-04L,
pS6 = -7.10526623669075243183e-06L,
qS1 = -2.94788392796209867269e+00L,
qS2 = 3.27309890266528636716e+00L,
qS3 = -1.68285799854822427013e+00L,
qS4 = 3.90699412641738801874e-01L,
qS5 = -3.14365703596053263322e-02L;
/*
* atanl()
*/
const long double atanhi[] = {
4.63647609000806116202e-01L,
7.85398163397448309628e-01L,
9.82793723247329067960e-01L,
1.57079632679489661926e+00L,
};
const long double atanlo[] = {
1.18469937025062860669e-20L,
-1.25413940316708300586e-20L,
2.55232234165405176172e-20L,
-2.50827880633416601173e-20L,
};
const long double aT[] = {
3.33333333333333333017e-01L,
-1.99999999999999632011e-01L,
1.42857142857046531280e-01L,
-1.11111111100562372733e-01L,
9.09090902935647302252e-02L,
-7.69230552476207730353e-02L,
6.66661718042406260546e-02L,
-5.88158892835030888692e-02L,
5.25499891539726639379e-02L,
-4.70119845393155721494e-02L,
4.03539201366454414072e-02L,
-2.91303858419364158725e-02L,
1.24822046299269234080e-02L,
};
const long double pi_lo = -5.01655761266833202345e-20L;

114
ld80/invtrig.h Normal file
View file

@ -0,0 +1,114 @@
/*-
* Copyright (c) 2008 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/ld80/invtrig.h,v 1.2 2008/08/02 03:56:22 das Exp $
*/
#include <float.h>
#include "fpmath.h"
#define BIAS (LDBL_MAX_EXP - 1)
#define MANH_SIZE LDBL_MANH_SIZE
/* Approximation thresholds. */
#define ASIN_LINEAR (BIAS - 32) /* 2**-32 */
#define ACOS_CONST (BIAS - 65) /* 2**-65 */
#define ATAN_CONST (BIAS + 65) /* 2**65 */
#define ATAN_LINEAR (BIAS - 32) /* 2**-32 */
/* 0.95 */
#define THRESH ((0xe666666666666666ULL>>(64-(MANH_SIZE-1)))|LDBL_NBIT)
/* Constants shared by the long double inverse trig functions. */
#define pS0 _ItL_pS0
#define pS1 _ItL_pS1
#define pS2 _ItL_pS2
#define pS3 _ItL_pS3
#define pS4 _ItL_pS4
#define pS5 _ItL_pS5
#define pS6 _ItL_pS6
#define qS1 _ItL_qS1
#define qS2 _ItL_qS2
#define qS3 _ItL_qS3
#define qS4 _ItL_qS4
#define qS5 _ItL_qS5
#define atanhi _ItL_atanhi
#define atanlo _ItL_atanlo
#define aT _ItL_aT
#define pi_lo _ItL_pi_lo
#define pio2_hi atanhi[3]
#define pio2_lo atanlo[3]
#define pio4_hi atanhi[1]
#ifdef STRUCT_DECLS
typedef struct longdouble {
uint64_t mant;
uint16_t expsign;
} LONGDOUBLE;
#else
typedef long double LONGDOUBLE;
#endif
extern const LONGDOUBLE pS0, pS1, pS2, pS3, pS4, pS5, pS6;
extern const LONGDOUBLE qS1, qS2, qS3, qS4, qS5;
extern const LONGDOUBLE atanhi[], atanlo[], aT[];
extern const LONGDOUBLE pi_lo;
#ifndef STRUCT_DECLS
static inline long double
P(long double x)
{
return (x * (pS0 + x * (pS1 + x * (pS2 + x * (pS3 + x * \
(pS4 + x * (pS5 + x * pS6)))))));
}
static inline long double
Q(long double x)
{
return (1.0 + x * (qS1 + x * (qS2 + x * (qS3 + x * (qS4 + x * qS5)))));
}
static inline long double
T_even(long double x)
{
return (aT[0] + x * (aT[2] + x * (aT[4] + x * (aT[6] + x * \
(aT[8] + x * (aT[10] + x * aT[12]))))));
}
static inline long double
T_odd(long double x)
{
return (aT[1] + x * (aT[3] + x * (aT[5] + x * (aT[7] + x * \
(aT[9] + x * aT[11])))));
}
#endif

78
ld80/k_cosl.c Normal file
View file

@ -0,0 +1,78 @@
/* From: @(#)k_cos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld80/k_cosl.c,v 1.1 2008/02/17 07:32:14 das Exp $");
/*
* ld80 version of k_cos.c. See ../src/k_cos.c for most comments.
*/
#include "math_private.h"
/*
* Domain [-0.7854, 0.7854], range ~[-2.43e-23, 2.425e-23]:
* |cos(x) - c(x)| < 2**-75.1
*
* The coefficients of c(x) were generated by a pari-gp script using
* a Remez algorithm that searches for the best higher coefficients
* after rounding leading coefficients to a specified precision.
*
* Simpler methods like Chebyshev or basic Remez barely suffice for
* cos() in 64-bit precision, because we want the coefficient of x^2
* to be precisely -0.5 so that multiplying by it is exact, and plain
* rounding of the coefficients of a good polynomial approximation only
* gives this up to about 64-bit precision. Plain rounding also gives
* a mediocre approximation for the coefficient of x^4, but a rounding
* error of 0.5 ulps for this coefficient would only contribute ~0.01
* ulps to the final error, so this is unimportant. Rounding errors in
* higher coefficients are even less important.
*
* In fact, coefficients above the x^4 one only need to have 53-bit
* precision, and this is more efficient. We get this optimization
* almost for free from the complications needed to search for the best
* higher coefficients.
*/
static const double
one = 1.0;
#if defined(__amd64__) || defined(__i386__)
/* Long double constants are slow on these arches, and broken on i386. */
static const volatile double
C1hi = 0.041666666666666664, /* 0x15555555555555.0p-57 */
C1lo = 2.2598839032744733e-18; /* 0x14d80000000000.0p-111 */
#define C1 ((long double)C1hi + C1lo)
#else
static const long double
C1 = 0.0416666666666666666136L; /* 0xaaaaaaaaaaaaaa9b.0p-68 */
#endif
static const double
C2 = -0.0013888888888888874, /* -0x16c16c16c16c10.0p-62 */
C3 = 0.000024801587301571716, /* 0x1a01a01a018e22.0p-68 */
C4 = -0.00000027557319215507120, /* -0x127e4fb7602f22.0p-74 */
C5 = 0.0000000020876754400407278, /* 0x11eed8caaeccf1.0p-81 */
C6 = -1.1470297442401303e-11, /* -0x19393412bd1529.0p-89 */
C7 = 4.7383039476436467e-14; /* 0x1aac9d9af5c43e.0p-97 */
long double
__kernel_cosl(long double x, long double y)
{
long double hz,z,r,w;
z = x*x;
r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*(C6+z*C7))))));
hz = 0.5*z;
w = one-hz;
return w + (((one-w)-hz) + (z*r-x*y));
}

62
ld80/k_sinl.c Normal file
View file

@ -0,0 +1,62 @@
/* From: @(#)k_sin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld80/k_sinl.c,v 1.1 2008/02/17 07:32:14 das Exp $");
/*
* ld80 version of k_sin.c. See ../src/k_sin.c for most comments.
*/
#include "math_private.h"
static const double
half = 0.5;
/*
* Domain [-0.7854, 0.7854], range ~[-1.89e-22, 1.915e-22]
* |sin(x)/x - s(x)| < 2**-72.1
*
* See ../ld80/k_cosl.c for more details about the polynomial.
*/
#if defined(__amd64__) || defined(__i386__)
/* Long double constants are slow on these arches, and broken on i386. */
static const volatile double
S1hi = -0.16666666666666666, /* -0x15555555555555.0p-55 */
S1lo = -9.2563760475949941e-18; /* -0x15580000000000.0p-109 */
#define S1 ((long double)S1hi + S1lo)
#else
static const long double
S1 = -0.166666666666666666671L; /* -0xaaaaaaaaaaaaaaab.0p-66 */
#endif
static const double
S2 = 0.0083333333333333332, /* 0x11111111111111.0p-59 */
S3 = -0.00019841269841269427, /* -0x1a01a01a019f81.0p-65 */
S4 = 0.0000027557319223597490, /* 0x171de3a55560f7.0p-71 */
S5 = -0.000000025052108218074604, /* -0x1ae64564f16cad.0p-78 */
S6 = 1.6059006598854211e-10, /* 0x161242b90243b5.0p-85 */
S7 = -7.6429779983024564e-13, /* -0x1ae42ebd1b2e00.0p-93 */
S8 = 2.6174587166648325e-15; /* 0x179372ea0b3f64.0p-101 */
long double
__kernel_sinl(long double x, long double y, int iy)
{
long double z,r,v;
z = x*x;
v = z*x;
r = S2+z*(S3+z*(S4+z*(S5+z*(S6+z*(S7+z*S8)))));
if(iy==0) return x+v*(S1+z*r);
else return x-((z*(half*y-v*r)-y)-v*S1);
}

124
ld80/k_tanl.c Normal file
View file

@ -0,0 +1,124 @@
/* From: @(#)k_tan.c 1.5 04/04/22 SMI */
/*
* ====================================================
* Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2008 Steven G. Kargl, David Schultz, Bruce D. Evans.
*
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld80/k_tanl.c,v 1.3 2008/02/18 15:39:52 bde Exp $");
/*
* ld80 version of k_tan.c. See ../src/k_tan.c for most comments.
*/
#include "math.h"
#include "math_private.h"
/*
* Domain [-0.67434, 0.67434], range ~[-2.25e-22, 1.921e-22]
* |tan(x)/x - t(x)| < 2**-71.9
*
* See k_cosl.c for more details about the polynomial.
*/
#if defined(__amd64__) || defined(__i386__)
/* Long double constants are slow on these arches, and broken on i386. */
static const volatile double
T3hi = 0.33333333333333331, /* 0x15555555555555.0p-54 */
T3lo = 1.8350121769317163e-17, /* 0x15280000000000.0p-108 */
T5hi = 0.13333333333333336, /* 0x11111111111112.0p-55 */
T5lo = 1.3051083651294260e-17, /* 0x1e180000000000.0p-109 */
T7hi = 0.053968253968250494, /* 0x1ba1ba1ba1b827.0p-57 */
T7lo = 3.1509625637859973e-18, /* 0x1d100000000000.0p-111 */
pio4_hi = 0.78539816339744828, /* 0x1921fb54442d18.0p-53 */
pio4_lo = 3.0628711372715500e-17, /* 0x11a80000000000.0p-107 */
pio4lo_hi = -1.2541394031670831e-20, /* -0x1d9cceba3f91f2.0p-119 */
pio4lo_lo = 6.1493048227390915e-37; /* 0x1a280000000000.0p-173 */
#define T3 ((long double)T3hi + T3lo)
#define T5 ((long double)T5hi + T5lo)
#define T7 ((long double)T7hi + T7lo)
#define pio4 ((long double)pio4_hi + pio4_lo)
#define pio4lo ((long double)pio4lo_hi + pio4lo_lo)
#else
static const long double
T3 = 0.333333333333333333180L, /* 0xaaaaaaaaaaaaaaa5.0p-65 */
T5 = 0.133333333333333372290L, /* 0x88888888888893c3.0p-66 */
T7 = 0.0539682539682504975744L, /* 0xdd0dd0dd0dc13ba2.0p-68 */
pio4 = 0.785398163397448309628L, /* 0xc90fdaa22168c235.0p-64 */
pio4lo = -1.25413940316708300586e-20L; /* -0xece675d1fc8f8cbb.0p-130 */
#endif
static const double
T9 = 0.021869488536312216, /* 0x1664f4882cc1c2.0p-58 */
T11 = 0.0088632355256619590, /* 0x1226e355c17612.0p-59 */
T13 = 0.0035921281113786528, /* 0x1d6d3d185d7ff8.0p-61 */
T15 = 0.0014558334756312418, /* 0x17da354aa3f96b.0p-62 */
T17 = 0.00059003538700862256, /* 0x13559358685b83.0p-63 */
T19 = 0.00023907843576635544, /* 0x1f56242026b5be.0p-65 */
T21 = 0.000097154625656538905, /* 0x1977efc26806f4.0p-66 */
T23 = 0.000038440165747303162, /* 0x14275a09b3ceac.0p-67 */
T25 = 0.000018082171885432524, /* 0x12f5e563e5487e.0p-68 */
T27 = 0.0000024196006108814377, /* 0x144c0d80cc6896.0p-71 */
T29 = 0.0000078293456938132840, /* 0x106b59141a6cb3.0p-69 */
T31 = -0.0000032609076735050182, /* -0x1b5abef3ba4b59.0p-71 */
T33 = 0.0000023261313142559411; /* 0x13835436c0c87f.0p-71 */
long double
__kernel_tanl(long double x, long double y, int iy) {
long double z, r, v, w, s;
long double osign;
int i;
iy = (iy == 1 ? -1 : 1); /* XXX recover original interface */
osign = (x >= 0 ? 1.0 : -1.0); /* XXX slow, probably wrong for -0 */
if (fabsl(x) >= 0.67434) {
if (x < 0) {
x = -x;
y = -y;
}
z = pio4 - x;
w = pio4lo - y;
x = z + w;
y = 0.0;
i = 1;
} else
i = 0;
z = x * x;
w = z * z;
r = T5 + w * (T9 + w * (T13 + w * (T17 + w * (T21 +
w * (T25 + w * (T29 + w * T33))))));
v = z * (T7 + w * (T11 + w * (T15 + w * (T19 + w * (T23 +
w * (T27 + w * T31))))));
s = z * x;
r = y + z * (s * (r + v) + y);
r += T3 * s;
w = x + r;
if (i == 1) {
v = (long double) iy;
return osign *
(v - 2.0 * (x - (w * w / (w + v) - r)));
}
if (iy == 1)
return w;
else {
/*
* if allow error up to 2 ulp, simply return
* -1.0 / (x+r) here
*/
/* compute -1.0 / (x+r) accurately */
long double a, t;
z = w;
z = z + 0x1p32 - 0x1p32;
v = r - (z - x); /* z+v = r+x */
t = a = -1.0 / w; /* a = -1.0/w */
t = t + 0x1p32 - 0x1p32;
s = 1.0 + t * z;
return t + a * (s + t * v);
}
}

294
ld80/s_exp2l.c Normal file
View file

@ -0,0 +1,294 @@
/*-
* Copyright (c) 2005-2008 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/msun/ld80/s_exp2l.c,v 1.3 2008/02/13 10:44:44 bde Exp $");
#include <float.h>
#include <stdint.h>
#ifdef __i386__
#include <ieeefp.h>
#endif
#include "fpmath.h"
#include "math.h"
#define TBLBITS 7
#define TBLSIZE (1 << TBLBITS)
#define BIAS (LDBL_MAX_EXP - 1)
#define EXPMASK (BIAS + LDBL_MAX_EXP)
static const long double huge = 0x1p10000L;
#if 0 /* XXX Prevent gcc from erroneously constant folding this. */
static const long double twom10000 = 0x1p-10000L;
#else
static volatile long double twom10000 = 0x1p-10000L;
#endif
static const double
redux = 0x1.8p63 / TBLSIZE,
P1 = 0x1.62e42fefa39efp-1,
P2 = 0x1.ebfbdff82c58fp-3,
P3 = 0x1.c6b08d7049fap-5,
P4 = 0x1.3b2ab6fba4da5p-7,
P5 = 0x1.5d8804780a736p-10,
P6 = 0x1.430918835e33dp-13;
static const double tbl[TBLSIZE * 2] = {
0x1.6a09e667f3bcdp-1, -0x1.bdd3413b2648p-55,
0x1.6c012750bdabfp-1, -0x1.2895667ff0cp-57,
0x1.6dfb23c651a2fp-1, -0x1.bbe3a683c88p-58,
0x1.6ff7df9519484p-1, -0x1.83c0f25860fp-56,
0x1.71f75e8ec5f74p-1, -0x1.16e4786887bp-56,
0x1.73f9a48a58174p-1, -0x1.0a8d96c65d5p-55,
0x1.75feb564267c9p-1, -0x1.0245957316ep-55,
0x1.780694fde5d3fp-1, 0x1.866b80a0216p-55,
0x1.7a11473eb0187p-1, -0x1.41577ee0499p-56,
0x1.7c1ed0130c132p-1, 0x1.f124cd1164ep-55,
0x1.7e2f336cf4e62p-1, 0x1.05d02ba157ap-57,
0x1.80427543e1a12p-1, -0x1.27c86626d97p-55,
0x1.82589994cce13p-1, -0x1.d4c1dd41533p-55,
0x1.8471a4623c7adp-1, -0x1.8d684a341cep-56,
0x1.868d99b4492edp-1, -0x1.fc6f89bd4f68p-55,
0x1.88ac7d98a6699p-1, 0x1.994c2f37cb5p-55,
0x1.8ace5422aa0dbp-1, 0x1.6e9f156864bp-55,
0x1.8cf3216b5448cp-1, -0x1.0d55e32e9e4p-57,
0x1.8f1ae99157736p-1, 0x1.5cc13a2e397p-56,
0x1.9145b0b91ffc6p-1, -0x1.dd6792e5825p-55,
0x1.93737b0cdc5e5p-1, -0x1.75fc781b58p-58,
0x1.95a44cbc8520fp-1, -0x1.64b7c96a5fp-57,
0x1.97d829fde4e5p-1, -0x1.d185b7c1b86p-55,
0x1.9a0f170ca07bap-1, -0x1.173bd91cee6p-55,
0x1.9c49182a3f09p-1, 0x1.c7c46b071f2p-57,
0x1.9e86319e32323p-1, 0x1.824ca78e64cp-57,
0x1.a0c667b5de565p-1, -0x1.359495d1cd5p-55,
0x1.a309bec4a2d33p-1, 0x1.6305c7ddc368p-55,
0x1.a5503b23e255dp-1, -0x1.d2f6edb8d42p-55,
0x1.a799e1330b358p-1, 0x1.bcb7ecac564p-55,
0x1.a9e6b5579fdbfp-1, 0x1.0fac90ef7fdp-55,
0x1.ac36bbfd3f37ap-1, -0x1.f9234cae76dp-56,
0x1.ae89f995ad3adp-1, 0x1.7a1cd345dcc8p-55,
0x1.b0e07298db666p-1, -0x1.bdef54c80e4p-55,
0x1.b33a2b84f15fbp-1, -0x1.2805e3084d8p-58,
0x1.b59728de5593ap-1, -0x1.c71dfbbba6ep-55,
0x1.b7f76f2fb5e47p-1, -0x1.5584f7e54acp-57,
0x1.ba5b030a1064ap-1, -0x1.efcd30e5429p-55,
0x1.bcc1e904bc1d2p-1, 0x1.23dd07a2d9fp-56,
0x1.bf2c25bd71e09p-1, -0x1.efdca3f6b9c8p-55,
0x1.c199bdd85529cp-1, 0x1.11065895049p-56,
0x1.c40ab5fffd07ap-1, 0x1.b4537e083c6p-55,
0x1.c67f12e57d14bp-1, 0x1.2884dff483c8p-55,
0x1.c8f6d9406e7b5p-1, 0x1.1acbc48805cp-57,
0x1.cb720dcef9069p-1, 0x1.503cbd1e94ap-57,
0x1.cdf0b555dc3fap-1, -0x1.dd83b53829dp-56,
0x1.d072d4a07897cp-1, -0x1.cbc3743797a8p-55,
0x1.d2f87080d89f2p-1, -0x1.d487b719d858p-55,
0x1.d5818dcfba487p-1, 0x1.2ed02d75b37p-56,
0x1.d80e316c98398p-1, -0x1.11ec18bedep-55,
0x1.da9e603db3285p-1, 0x1.c2300696db5p-55,
0x1.dd321f301b46p-1, 0x1.2da5778f019p-55,
0x1.dfc97337b9b5fp-1, -0x1.1a5cd4f184b8p-55,
0x1.e264614f5a129p-1, -0x1.7b627817a148p-55,
0x1.e502ee78b3ff6p-1, 0x1.39e8980a9cdp-56,
0x1.e7a51fbc74c83p-1, 0x1.2d522ca0c8ep-55,
0x1.ea4afa2a490dap-1, -0x1.e9c23179c288p-55,
0x1.ecf482d8e67f1p-1, -0x1.c93f3b411ad8p-55,
0x1.efa1bee615a27p-1, 0x1.dc7f486a4b68p-55,
0x1.f252b376bba97p-1, 0x1.3a1a5bf0d8e8p-55,
0x1.f50765b6e454p-1, 0x1.9d3e12dd8a18p-55,
0x1.f7bfdad9cbe14p-1, -0x1.dbb12d00635p-55,
0x1.fa7c1819e90d8p-1, 0x1.74853f3a593p-56,
0x1.fd3c22b8f71f1p-1, 0x1.2eb74966578p-58,
0x1p+0, 0x0p+0,
0x1.0163da9fb3335p+0, 0x1.b61299ab8cd8p-54,
0x1.02c9a3e778061p+0, -0x1.19083535b08p-56,
0x1.04315e86e7f85p+0, -0x1.0a31c1977c98p-54,
0x1.059b0d3158574p+0, 0x1.d73e2a475b4p-55,
0x1.0706b29ddf6dep+0, -0x1.c91dfe2b13cp-55,
0x1.0874518759bc8p+0, 0x1.186be4bb284p-57,
0x1.09e3ecac6f383p+0, 0x1.14878183161p-54,
0x1.0b5586cf9890fp+0, 0x1.8a62e4adc61p-54,
0x1.0cc922b7247f7p+0, 0x1.01edc16e24f8p-54,
0x1.0e3ec32d3d1a2p+0, 0x1.03a1727c58p-59,
0x1.0fb66affed31bp+0, -0x1.b9bedc44ebcp-57,
0x1.11301d0125b51p+0, -0x1.6c51039449bp-54,
0x1.12abdc06c31ccp+0, -0x1.1b514b36ca8p-58,
0x1.1429aaea92dep+0, -0x1.32fbf9af1368p-54,
0x1.15a98c8a58e51p+0, 0x1.2406ab9eeabp-55,
0x1.172b83c7d517bp+0, -0x1.19041b9d78ap-55,
0x1.18af9388c8deap+0, -0x1.11023d1970f8p-54,
0x1.1a35beb6fcb75p+0, 0x1.e5b4c7b4969p-55,
0x1.1bbe084045cd4p+0, -0x1.95386352ef6p-54,
0x1.1d4873168b9aap+0, 0x1.e016e00a264p-54,
0x1.1ed5022fcd91dp+0, -0x1.1df98027bb78p-54,
0x1.2063b88628cd6p+0, 0x1.dc775814a85p-55,
0x1.21f49917ddc96p+0, 0x1.2a97e9494a6p-55,
0x1.2387a6e756238p+0, 0x1.9b07eb6c7058p-54,
0x1.251ce4fb2a63fp+0, 0x1.ac155bef4f5p-55,
0x1.26b4565e27cddp+0, 0x1.2bd339940eap-55,
0x1.284dfe1f56381p+0, -0x1.a4c3a8c3f0d8p-54,
0x1.29e9df51fdee1p+0, 0x1.612e8afad12p-55,
0x1.2b87fd0dad99p+0, -0x1.10adcd6382p-59,
0x1.2d285a6e4030bp+0, 0x1.0024754db42p-54,
0x1.2ecafa93e2f56p+0, 0x1.1ca0f45d524p-56,
0x1.306fe0a31b715p+0, 0x1.6f46ad23183p-55,
0x1.32170fc4cd831p+0, 0x1.a9ce78e1804p-55,
0x1.33c08b26416ffp+0, 0x1.327218436598p-54,
0x1.356c55f929ff1p+0, -0x1.b5cee5c4e46p-55,
0x1.371a7373aa9cbp+0, -0x1.63aeabf42ebp-54,
0x1.38cae6d05d866p+0, -0x1.e958d3c99048p-54,
0x1.3a7db34e59ff7p+0, -0x1.5e436d661f6p-56,
0x1.3c32dc313a8e5p+0, -0x1.efff8375d2ap-54,
0x1.3dea64c123422p+0, 0x1.ada0911f09fp-55,
0x1.3fa4504ac801cp+0, -0x1.7d023f956fap-54,
0x1.4160a21f72e2ap+0, -0x1.ef3691c309p-58,
0x1.431f5d950a897p+0, -0x1.1c7dde35f7ap-55,
0x1.44e086061892dp+0, 0x1.89b7a04ef8p-59,
0x1.46a41ed1d0057p+0, 0x1.c944bd1648a8p-54,
0x1.486a2b5c13cdp+0, 0x1.3c1a3b69062p-56,
0x1.4a32af0d7d3dep+0, 0x1.9cb62f3d1be8p-54,
0x1.4bfdad5362a27p+0, 0x1.d4397afec42p-56,
0x1.4dcb299fddd0dp+0, 0x1.8ecdbbc6a78p-54,
0x1.4f9b2769d2ca7p+0, -0x1.4b309d25958p-54,
0x1.516daa2cf6642p+0, -0x1.f768569bd94p-55,
0x1.5342b569d4f82p+0, -0x1.07abe1db13dp-55,
0x1.551a4ca5d920fp+0, -0x1.d689cefede6p-55,
0x1.56f4736b527dap+0, 0x1.9bb2c011d938p-54,
0x1.58d12d497c7fdp+0, 0x1.295e15b9a1ep-55,
0x1.5ab07dd485429p+0, 0x1.6324c0546478p-54,
0x1.5c9268a5946b7p+0, 0x1.c4b1b81698p-60,
0x1.5e76f15ad2148p+0, 0x1.ba6f93080e68p-54,
0x1.605e1b976dc09p+0, -0x1.3e2429b56de8p-54,
0x1.6247eb03a5585p+0, -0x1.383c17e40b48p-54,
0x1.6434634ccc32p+0, -0x1.c483c759d89p-55,
0x1.6623882552225p+0, -0x1.bb60987591cp-54,
0x1.68155d44ca973p+0, 0x1.038ae44f74p-57,
};
/*
* exp2l(x): compute the base 2 exponential of x
*
* Accuracy: Peak error < 0.511 ulp.
*
* Method: (equally-spaced tables)
*
* Reduce x:
* x = 2**k + y, for integer k and |y| <= 1/2.
* Thus we have exp2l(x) = 2**k * exp2(y).
*
* Reduce y:
* y = i/TBLSIZE + z for integer i near y * TBLSIZE.
* Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z),
* with |z| <= 2**-(TBLBITS+1).
*
* We compute exp2(i/TBLSIZE) via table lookup and exp2(z) via a
* degree-6 minimax polynomial with maximum error under 2**-69.
* The table entries each have 104 bits of accuracy, encoded as
* a pair of double precision values.
*/
long double
exp2l(long double x)
{
union IEEEl2bits u, v;
long double r, twopk, twopkp10000, z;
uint32_t hx, ix, i0;
int k;
/* Filter out exceptional cases. */
u.e = x;
hx = u.xbits.expsign;
ix = hx & EXPMASK;
if (ix >= BIAS + 14) { /* |x| >= 16384 or x is NaN */
if (ix == BIAS + LDBL_MAX_EXP) {
if (u.xbits.man != 1ULL << 63 || (hx & 0x8000) == 0)
return (x + x); /* x is +Inf or NaN */
else
return (0.0); /* x is -Inf */
}
if (x >= 16384)
return (huge * huge); /* overflow */
if (x <= -16446)
return (twom10000 * twom10000); /* underflow */
} else if (ix <= BIAS - 66) { /* |x| < 0x1p-66 */
return (1.0 + x);
}
#ifdef __i386__
/*
* The default precision on i386 is 53 bits, so long doubles are
* broken. Call exp2() to get an accurate (double precision) result.
*/
if (fpgetprec() != FP_PE)
return (exp2(x));
#endif
/*
* Reduce x, computing z, i0, and k. The low bits of x + redux
* contain the 16-bit integer part of the exponent (k) followed by
* TBLBITS fractional bits (i0). We use bit tricks to extract these
* as integers, then set z to the remainder.
*
* Example: Suppose x is 0xabc.123456p0 and TBLBITS is 8.
* Then the low-order word of x + redux is 0x000abc12,
* We split this into k = 0xabc and i0 = 0x12 (adjusted to
* index into the table), then we compute z = 0x0.003456p0.
*
* XXX If the exponent is negative, the computation of k depends on
* '>>' doing sign extension.
*/
u.e = x + redux;
i0 = u.bits.manl + TBLSIZE / 2;
k = (int)i0 >> TBLBITS;
i0 = (i0 & (TBLSIZE - 1)) << 1;
u.e -= redux;
z = x - u.e;
v.xbits.man = 1ULL << 63;
if (k >= LDBL_MIN_EXP) {
v.xbits.expsign = LDBL_MAX_EXP - 1 + k;
twopk = v.e;
} else {
v.xbits.expsign = LDBL_MAX_EXP - 1 + k + 10000;
twopkp10000 = v.e;
}
/* Compute r = exp2l(y) = exp2lt[i0] * p(z). */
long double t_hi = tbl[i0];
long double t_lo = tbl[i0 + 1];
/* XXX This gives > 1 ulp errors outside of FE_TONEAREST mode */
r = t_lo + (t_hi + t_lo) * z * (P1 + z * (P2 + z * (P3 + z * (P4
+ z * (P5 + z * P6))))) + t_hi;
/* Scale by 2**k. */
if (k >= LDBL_MIN_EXP) {
if (k == LDBL_MAX_EXP)
return (r * 2.0 * 0x1p16383L);
return (r * twopk);
} else {
return (r * twopkp10000 * twom10000);
}
}

46
ld80/s_nanl.c Normal file
View file

@ -0,0 +1,46 @@
/*-
* Copyright (c) 2007 David Schultz
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/ld80/s_nanl.c,v 1.2 2007/12/18 23:46:31 das Exp $
*/
#include <math.h>
#include "fpmath.h"
#include "../src/math_private.h"
long double
nanl(const char *s)
{
union {
union IEEEl2bits ieee;
uint32_t bits[3];
} u;
_scan_nan(u.bits, 3, s);
u.ieee.bits.exp = 0x7fff;
u.ieee.bits.manh |= 0xc0000000; /* make it a quiet NaN */
return (u.ieee.e);
}

87
man/acos.3 Normal file
View file

@ -0,0 +1,87 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)acos.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/acos.3,v 1.15 2008/07/31 22:41:26 das Exp $
.\"
.Dd July 31, 2008
.Dt ACOS 3
.Os
.Sh NAME
.Nm acos ,
.Nm acosf ,
.Nm acosl
.Nd arc cosine functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn acos "double x"
.Ft float
.Fn acosf "float x"
.Ft long double
.Fn acosl "long double x"
.Sh DESCRIPTION
The
.Fn acos ,
.Fn acosf ,
and
.Fn acosl
functions compute the principal value of the arc cosine of
.Fa x .
.Sh RETURN VALUES
These functions return the arc cosine in the range
.Bq 0 , \*(Pi
radians.
If:
.Bd -unfilled -offset indent
.Pf \&| Ns Ar x Ns \&| > 1 ,
.Ed
.Pp
.Fn acos x
raises an invalid exception and returns an \*(Na.
.Sh SEE ALSO
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr fenv 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Sh STANDARDS
The
.Fn acos ,
.Fn acosf ,
and
.Fn acosl
functions conform to
.St -isoC-99 .

78
man/acosh.3 Normal file
View file

@ -0,0 +1,78 @@
.\" Copyright (c) 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)acosh.3 5.2 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/acosh.3,v 1.12 2007/01/09 01:02:05 imp Exp $
.\"
.Dd January 14, 2005
.Dt ACOSH 3
.Os
.Sh NAME
.Nm acosh ,
.Nm acoshf
.Nd inverse hyperbolic cosine functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn acosh "double x"
.Ft float
.Fn acoshf "float x"
.Sh DESCRIPTION
The
.Fn acosh
and the
.Fn acoshf
functions compute the inverse hyperbolic cosine
of the real
argument
.Ar x .
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
The
.Fn acosh
and the
.Fn acoshf
functions
return the inverse hyperbolic cosine of
.Ar x .
If the argument is less than 1,
.Fn acosh
raises an invalid exception and returns an \*(Na.
.Sh SEE ALSO
.Xr asinh 3 ,
.Xr atanh 3 ,
.Xr exp 3 ,
.Xr fenv 3 ,
.Xr math 3
.Sh HISTORY
The
.Fn acosh
function appeared in
.Bx 4.3 .

89
man/asin.3 Normal file
View file

@ -0,0 +1,89 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)asin.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/asin.3,v 1.17 2008/07/31 22:41:26 das Exp $
.\"
.Dd July 31, 2008
.Dt ASIN 3
.Os
.Sh NAME
.Nm asin ,
.Nm asinf ,
.Nm asinl
.Nd arc sine functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn asin "double x"
.Ft float
.Fn asinf "float x"
.Ft long double
.Fn asinl "long double x"
.Sh DESCRIPTION
The
.Fn asin ,
.Fn asinf ,
and
.Fn asinl
functions compute the principal value of the arc sine of
.Fa x .
.Sh RETURN VALUES
These functions return the arc sine in the range
.Bk -words
.Bq -\*(Pi/2 , +\*(Pi/2
.Ek
radians.
If:
.Bd -unfilled -offset indent
.Pf \&| Ns Ar x Ns \&| > 1
.Ed
.Pp
.Fn asin x
raises an invalid exception and returns an \*(Na.
.Sh SEE ALSO
.Xr acos 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr fenv 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Sh STANDARDS
The
.Fn asin ,
.Fn asinf ,
and
.Fn asinl
functions conform to
.St -isoC-99 .

74
man/asinh.3 Normal file
View file

@ -0,0 +1,74 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)asinh.3 6.4 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/asinh.3,v 1.11 2007/01/09 01:02:05 imp Exp $
.\"
.Dd May 6, 1991
.Dt ASINH 3
.Os
.Sh NAME
.Nm asinh ,
.Nm asinhf
.Nd inverse hyperbolic sine functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn asinh "double x"
.Ft float
.Fn asinhf "float x"
.Sh DESCRIPTION
The
.Fn asinh
and the
.Fn asinhf
functions compute the inverse hyperbolic sine
of the real
argument
.Ar x .
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
The
.Fn asinh
and the
.Fn asinhf
functions
return the inverse hyperbolic sine of
.Ar x .
.Sh SEE ALSO
.Xr acosh 3 ,
.Xr atanh 3 ,
.Xr exp 3 ,
.Xr math 3
.Sh HISTORY
The
.Fn asinh
function appeared in
.Bx 4.3 .

81
man/atan.3 Normal file
View file

@ -0,0 +1,81 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)atan.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/atan.3,v 1.12 2008/07/31 22:41:26 das Exp $
.\"
.Dd July 31, 2008
.Dt ATAN 3
.Os
.Sh NAME
.Nm atan ,
.Nm atanf ,
.Nm atanl
.Nd arc tangent functions of one variable
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn atan "double x"
.Ft float
.Fn atanf "float x"
.Ft long double
.Fn atanl "long double x"
.Sh DESCRIPTION
The
.Fn atan ,
.Fn atanf ,
and
.Fn atanl
functions compute the principal value of the arc tangent of
.Fa x .
.Sh RETURN VALUES
These functions return the arc tangent in the range
.Bk -words
.Bq -\*(Pi/2 , +\*(Pi/2
.Ek
radians.
.Sh SEE ALSO
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan2 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Sh STANDARDS
The
.Fn atan ,
.Fn atanf ,
and
.Fn atanl
functions conform to
.St -isoC-99 .

225
man/atan2.3 Normal file
View file

@ -0,0 +1,225 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)atan2.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/atan2.3,v 1.20 2010/06/09 07:31:32 uqs Exp $
.\"
.Dd July 31, 2008
.Dt ATAN2 3
.Os
.Sh NAME
.Nm atan2 ,
.Nm atan2f ,
.Nm atan2l ,
.Nm carg ,
.Nm cargf ,
.Nm cargl
.Nd arc tangent and complex phase angle functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn atan2 "double y" "double x"
.Ft float
.Fn atan2f "float y" "float x"
.Ft long double
.Fn atan2l "long double y" "long double x"
.In complex.h
.Ft double
.Fn carg "double complex z"
.Ft float
.Fn cargf "float complex z"
.Ft long double
.Fn cargl "long double complex z"
.Sh DESCRIPTION
The
.Fn atan2 ,
.Fn atan2f ,
and
.Fn atan2l
functions compute the principal value of the arc tangent of
.Fa y/ Ns Ar x ,
using the signs of both arguments to determine the quadrant of
the return value.
.Pp
The
.Fn carg ,
.Fn cargf ,
and
.Fn cargl
functions compute the complex argument (or phase angle) of
.Fa z .
The complex argument is the number theta such that
.Li z = r * e^(I * theta) ,
where
.Li r = cabs(z) .
The call
.Li carg(z)
is equivalent to
.Li atan2(cimag(z), creal(z)) ,
and similarly for
.Fn cargf
and
.Fn cargl .
.Sh RETURN VALUES
The
.Fn atan2 ,
.Fn atan2f ,
and
.Fn atan2l
functions, if successful,
return the arc tangent of
.Fa y/ Ns Ar x
in the range
.Bk -words
.Bq \&- Ns \*(Pi , \&+ Ns \*(Pi
.Ek
radians.
Here are some of the special cases:
.Bl -column atan_(y,x)_:=____ sign(y)_(Pi_atan2(Xy_xX))___
.It Fn atan2 y x No := Ta
.Fn atan y/x Ta
if
.Ar x
> 0,
.It Ta sign( Ns Ar y Ns )*(\*(Pi -
.Fn atan "\*(Bay/x\*(Ba" ) Ta
if
.Ar x
< 0,
.It Ta
.No 0 Ta
if x = y = 0, or
.It Ta
.Pf sign( Ar y Ns )*\*(Pi/2 Ta
if
.Ar x
= 0 \(!=
.Ar y .
.El
.Sh NOTES
The function
.Fn atan2
defines "if x > 0,"
.Fn atan2 0 0
= 0 despite that previously
.Fn atan2 0 0
may have generated an error message.
The reasons for assigning a value to
.Fn atan2 0 0
are these:
.Bl -enum -offset indent
.It
Programs that test arguments to avoid computing
.Fn atan2 0 0
must be indifferent to its value.
Programs that require it to be invalid are vulnerable
to diverse reactions to that invalidity on diverse computer systems.
.It
The
.Fn atan2
function is used mostly to convert from rectangular (x,y)
to polar
.if n\
(r,theta)
.if t\
(r,\(*h)
coordinates that must satisfy x =
.if n\
r\(**cos theta
.if t\
r\(**cos\(*h
and y =
.if n\
r\(**sin theta.
.if t\
r\(**sin\(*h.
These equations are satisfied when (x=0,y=0)
is mapped to
.if n \
(r=0,theta=0).
.if t \
(r=0,\(*h=0).
In general, conversions to polar coordinates
should be computed thus:
.Bd -unfilled -offset indent
.if n \{\
r := hypot(x,y); ... := sqrt(x\(**x+y\(**y)
theta := atan2(y,x).
.\}
.if t \{\
r := hypot(x,y); ... := \(sr(x\u\s82\s10\d+y\u\s82\s10\d)
\(*h := atan2(y,x).
.\}
.Ed
.It
The foregoing formulas need not be altered to cope in a
reasonable way with signed zeros and infinities
on a machine that conforms to
.Tn IEEE 754 ;
the versions of
.Xr hypot 3
and
.Fn atan2
provided for
such a machine are designed to handle all cases.
That is why
.Fn atan2 \(+-0 \-0
= \(+-\*(Pi
for instance.
In general the formulas above are equivalent to these:
.Bd -unfilled -offset indent
.if n \
r := sqrt(x\(**x+y\(**y); if r = 0 then x := copysign(1,x);
.if t \
r := \(sr(x\(**x+y\(**y);\0\0if r = 0 then x := copysign(1,x);
.Ed
.El
.Sh SEE ALSO
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan 3 ,
.Xr cabs 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Sh STANDARDS
The
.Fn atan2 ,
.Fn atan2f ,
.Fn atan2l ,
.Fn carg ,
.Fn cargf ,
and
.Fn cargl
functions conform to
.St -isoC-99 .

81
man/atanh.3 Normal file
View file

@ -0,0 +1,81 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)atanh.3 5.2 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/atanh.3,v 1.14 2007/01/09 01:02:05 imp Exp $
.\"
.Dd January 14, 2005
.Dt ATANH 3
.Os
.Sh NAME
.Nm atanh ,
.Nm atanhf
.Nd inverse hyperbolic tangent functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn atanh "double x"
.Ft float
.Fn atanhf "float x"
.Sh DESCRIPTION
The
.Fn atanh
and the
.Fn atanhf
functions compute the inverse hyperbolic tangent
of the real
argument
.Ar x .
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
The
.Fn atanh
and the
.Fn atanhf
functions
return the inverse hyperbolic tangent of
.Ar x
if successful.
If the argument has absolute value 1, a divide-by-zero exception
is raised and an infinity is returned.
If
.Ar |x|
> 1, an invalid exception is raised and an \*(Na is returned.
.Sh SEE ALSO
.Xr acosh 3 ,
.Xr asinh 3 ,
.Xr exp 3 ,
.Xr fenv 3 ,
.Xr math 3
.Sh HISTORY
The
.Fn atanh
function appeared in
.Bx 4.3 .

80
man/ccos.3 Normal file
View file

@ -0,0 +1,80 @@
.\" Copyright (c) 2011 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/ccos.3,v 1.1 2011/10/17 05:41:03 das Exp $
.\"
.Dd October 17, 2011
.Dt CCOS 3
.Os
.Sh NAME
.Nm ccos ,
.Nm ccosf ,
.Nm csin ,
.Nm csinf
.Nm ctan ,
.Nm ctanf
.Nd complex trigonometric functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In complex.h
.Ft double complex
.Fn ccos "double complex z"
.Ft float complex
.Fn ccosf "float complex z"
.Ft double complex
.Fn csin "double complex z"
.Ft float complex
.Fn csinf "float complex z"
.Ft double complex
.Fn ctan "double complex z"
.Ft float complex
.Fn ctanf "float complex z"
.Sh DESCRIPTION
The
.Fn ccos ,
.Fn csin ,
and
.Fn ctan
functions compute the cosine, sine, and tangent of the complex number
.Fa z ,
respectively.
The
.Fn ccosf ,
.Fn csinf ,
and
.Fn ctanf
functions perform the same operations in
.Fa float
precision.
.Sh SEE ALSO
.Xr ccosh 3 ,
.Xr complex 3 ,
.Xr cos 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr tan 3
.Sh STANDARDS
These functions conform to
.St -isoC-99 .

80
man/ccosh.3 Normal file
View file

@ -0,0 +1,80 @@
.\" Copyright (c) 2011 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/ccosh.3,v 1.1 2011/10/17 05:41:03 das Exp $
.\"
.Dd October 17, 2011
.Dt CCOSH 3
.Os
.Sh NAME
.Nm ccosh ,
.Nm ccoshf ,
.Nm csinh ,
.Nm csinhf
.Nm ctanh ,
.Nm ctanhf
.Nd complex hyperbolic functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In complex.h
.Ft double complex
.Fn ccosh "double complex z"
.Ft float complex
.Fn ccoshf "float complex z"
.Ft double complex
.Fn csinh "double complex z"
.Ft float complex
.Fn csinhf "float complex z"
.Ft double complex
.Fn ctanh "double complex z"
.Ft float complex
.Fn ctanhf "float complex z"
.Sh DESCRIPTION
The
.Fn ccosh ,
.Fn csinh ,
and
.Fn ctanh
functions compute the hyperbolic cosine, sine, and tangent of the complex number
.Fa z ,
respectively.
The
.Fn ccoshf ,
.Fn csinhf ,
and
.Fn ctanhf
functions perform the same operations in
.Fa float
precision.
.Sh SEE ALSO
.Xr ccos 3 ,
.Xr complex 3 ,
.Xr cosh 3 ,
.Xr math 3 ,
.Xr sinh 3 ,
.Xr tanh 3
.Sh STANDARDS
These functions conform to
.St -isoC-99 .

78
man/ceil.3 Normal file
View file

@ -0,0 +1,78 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ceil.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/ceil.3,v 1.16 2007/01/09 01:02:05 imp Exp $
.\"
.Dd January 13, 2005
.Dt CEIL 3
.Os
.Sh NAME
.Nm ceil ,
.Nm ceilf ,
.Nm ceill
.Nd smallest integral value greater than or equal to x
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn ceil "double x"
.Ft float
.Fn ceilf "float x"
.Ft "long double"
.Fn ceill "long double x"
.Sh DESCRIPTION
The
.Fn ceil ,
.Fn ceilf
and
.Fn ceill
functions return the smallest integral value
greater than or equal to
.Fa x ,
expressed as a floating-point number.
.Sh SEE ALSO
.Xr abs 3 ,
.Xr fabs 3 ,
.Xr floor 3 ,
.Xr ieee 3 ,
.Xr math 3 ,
.Xr rint 3 ,
.Xr round 3 ,
.Xr trunc 3
.Sh STANDARDS
The
.Fn ceil
function conforms to
.St -isoC .
The
.Fn ceilf
and
.Fn ceill
functions conform to
.St -isoC-99 .

113
man/cexp.3 Normal file
View file

@ -0,0 +1,113 @@
.\" Copyright (c) 2011 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/cexp.3,v 1.1 2011/03/07 03:09:24 das Exp $
.\"
.Dd March 6, 2011
.Dt CEXP 3
.Os
.Sh NAME
.Nm cexp ,
.Nm cexpf
.Nd complex exponential functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In complex.h
.Ft double complex
.Fn cexp "double complex z"
.Ft float complex
.Fn cexpf "float complex z"
.Sh DESCRIPTION
The
.Fn cexp
and
.Fn cexpf
functions compute the complex exponential of
.Fa z ,
also known as
.Em cis Ns ( Ns
.Fa z Ns )
.Sh RETURN VALUES
For real numbers
.Fa x
and
.Fa y ,
.Fn cexp
behaves according to Euler's formula:
.Bd -ragged -offset indent
.Fn cexp "x + I*y"
=
.Ns ( Sy e Ns ** Ns
.Fa x *
.Em cos Ns ( Ns
.Fa y Ns )) + ( Ns
.Sy I
*
.Sy e Ns ** Ns
.Fa x
*
.Em sin Ns ( Ns
.Fa y Ns ))
.Ed
.Pp
Generally speaking, infinities, zeroes and \*(Nas are handled as would
be expected from this identity given the usual rules of floating-point
arithmetic.
However, care is taken to avoid generating \*(Nas when they are not deserved.
For example, mathematically we expect that
.Fo cimag
.Fn cexp "x + I*0" Fc
= 0 regardless of the value of
.Fa x ,
and
.Fn cexp
preserves this identity even if
.Fa x
is \*(If or \*(Na.
Likewise,
.Fn cexp "-\*(If + I*y"
= 0 and
.Fo creal
.Fn cexp "\*(If + I*y" Fc
= \*(If
for any
.Fa y
(even though the latter property is only mathematically true for
representable
.Fa y . )
If
.Fa y
is not finite, the sign of the result is indeterminate.
.Sh SEE ALSO
.Xr complex 3 ,
.Xr exp 3 ,
.Xr math 3 ,
.Sh STANDARDS
The
.Fn cexp
and
.Fn cexpf
functions conform to
.St -isoC-99 .

121
man/cimag.3 Normal file
View file

@ -0,0 +1,121 @@
.\" Copyright (c) 2004 Stefan Farfeleder
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/cimag.3,v 1.4 2010/03/12 10:01:06 uqs Exp $
.\"
.Dd August 7, 2008
.Dt CIMAG 3
.Os
.Sh NAME
.Nm cimag , cimagf , cimagl ,
.Nm conj , conjf , conjl ,
.Nm cproj , cprojf , cprojl ,
.Nm creal , crealf , creall
.Nd "functions to manipulate complex numbers"
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In complex.h
.Ft double
.Fn cimag "double complex z"
.Ft float
.Fn cimagf "float complex z"
.Ft "long double"
.Fn cimagl "long double complex z"
.Ft "double complex"
.Fn conj "double complex z"
.Ft "float complex"
.Fn conjf "float complex z"
.Ft "long double complex"
.Fn conjl "long double complex z"
.Ft "double complex"
.Fn cproj "double complex z"
.Ft "float complex"
.Fn cprojf "float complex z"
.Ft "long double complex"
.Fn cprojl "long double complex z"
.Ft double
.Fn creal "double complex z"
.Ft float
.Fn crealf "float complex z"
.Ft "long double"
.Fn creall "long double complex z"
.Sh DESCRIPTION
Let
.Sm off
.Fa a + b * Em i
.Sm on
denote the complex number
.Fa z .
.Pp
The
.Fn creal
functions return the real part
.Fa a ,
and the
.Fn cimag
functions return the imaginary part
.Fa b .
.Pp
The
.Fn conj
functions return the complex conjugate
.Sm off
.Fa a - b * Em i .
.Sm on
.Pp
The
.Fn cproj
functions return the projection onto the Riemann sphere.
If
.Fa z
contains an infinite component, then the result is
.Fa \*(If \*(Pm 0 Ns * Ns Em i ,
where the (zero) imaginary part of the result has the same sign as
.Fa b .
Otherwise, the result is
.Fa z .
.Pp
These functions do not signal any floating point exceptions.
.Sh STANDARDS
The
.Fn cimag ,
.Fn conj ,
.Fn cproj ,
and
.Fn creal
functions conform to
.St -isoC-99 .
.Sh HISTORY
The
.Fn cimag ,
.Fn conj
and
.Fn creal
functions first appeared in
.Fx 5.3 .
The
.Fn cproj
functions appeared in
.Fx 8.0 .

130
man/complex.3 Normal file
View file

@ -0,0 +1,130 @@
.\" Copyright (c) 2011 Murray Stokely <murray@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/complex.3,v 1.3 2011/10/17 05:41:03 das Exp $
.\"
.Dd October 17, 2011
.Dt COMPLEX 3
.Os
.Sh NAME
.Nm complex
.Nd "complex arithmetic"
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In complex.h
.Sh DESCRIPTION
These functions support complex arithmetic in the C math library.
.Sh "LIST OF FUNCTIONS"
Each of the following
.Vt "double complex"
functions has a
.Vt "float complex"
counterpart with an
.Ql f
appended to the name and a
.Vt "long double complex"
counterpart with an
.Ql l
appended.
As an example, the
.Vt "float complex"
and
.Vt "long double complex"
counterparts of
.Ft double
.Fn cabs "double complex z"
are
.Ft float
.Fn cabsf "float complex z"
and
.Ft "long double"
.Fn cabsl "long double complex z" ,
respectively.
.de Cl
.Bl -column "csqrt" "complex absolute value (i.e. norm, modulus, magnitude)"
.Em "Name Description"
..
.\" Section 7.3.5 - 7.3.7 of ISO C99 standard unimplemented, see BUGS
.\" Section 7.3.8 of ISO C99 standard
.Ss Absolute-value Functions
.Cl
cabs complex absolute value (i.e. norm, modulus, magnitude)
csqrt complex square root
.El
.Ss Exponential Function
.Cl
cexp exponential base e
.El
.\" Section 7.3.9 of ISO C99 standard
.Ss Manipulation Functions
.Cl
carg compute the argument (i.e. phase angle)
cimag compute the imaginary part
conj compute the complex conjugate
cproj compute projection onto Riemann sphere
creal compute the real part
.El
.\" Section 7.3.5-6 of ISO C99 standard
.Ss Trigonometric and Hyperbolic Functions
.Cl
ccos cosine
ccosh hyperbolic cosine
csin sine
csinh hyperbolic sine
ctan tangent
ctanh hyperbolic tangent
.El
.Sh SEE ALSO
.Xr math 3 ,
.Xr fenv 3 ,
.Xr ieee 3 ,
.Xr tgmath 3
.Rs
.%T "ISO/IEC 9899:TC3"
.%U http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
.Re
.Sh STANDARDS
The
.In complex.h
functions described here conform to
.St -isoC-99 .
.Sh BUGS
The inverse trigonmetric and hyperbolic functions
.Fn cacos ,
.Fn cacosh ,
.Fn casin ,
.Fn casinh ,
.Fn catan ,
and
.Fn catanh
are not implemented.
.Pp
The logarithmic functions
.Fn clog
are not implemented.
.Pp
The power functions
.Fn cpow
are not implemented.

86
man/copysign.3 Normal file
View file

@ -0,0 +1,86 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/copysign.3,v 1.2 2007/01/09 01:02:05 imp Exp $
.\"
.Dd January 26, 2005
.Dt COPYSIGN 3
.Os
.Sh NAME
.Nm copysign ,
.Nm copysignf ,
.Nm copysignl
.Nd copy sign
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn copysign "double x" "double y"
.Ft float
.Fn copysignf "float x" "float y"
.Ft long double
.Fn copysignl "long double x" "long double y"
.Sh DESCRIPTION
The
.Fn copysign ,
.Fn copysignf
and
.Fn copysignl
functions
return
.Fa x
with its sign changed to
.Fa y Ns 's .
.Sh SEE ALSO
.Xr fabs 3 ,
.Xr fdim 3 ,
.Xr ieee 3 ,
.Xr math 3
.Sh STANDARDS
The
.Fn copysign ,
.Fn copysignf ,
and
.Fn copysignl
routines conform to
.St -isoC-99 .
They implement the Copysign function recommended by
.St -ieee754 .
.Sh HISTORY
The
.Fn copysign ,
.Fn copysignf ,
and
.Fn copysignl
functions appeared in
.Bx 4.3 ,
.Fx 2.0 ,
and
.Fx 5.3 ,
respectively.

83
man/cos.3 Normal file
View file

@ -0,0 +1,83 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)cos.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/cos.3,v 1.15 2011/10/17 05:41:03 das Exp $
.\"
.Dd January 24, 2008
.Dt COS 3
.Os
.Sh NAME
.Nm cos ,
.Nm cosf ,
.Nm cosl
.Nd cosine functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn cos "double x"
.Ft float
.Fn cosf "float x"
.Ft long double
.Fn cosl "long double x"
.Sh DESCRIPTION
The
.Fn cos ,
.Fn cosf ,
and
.Fn cosl
functions compute the cosine of
.Fa x
(measured in radians).
A large magnitude argument may yield a result with little or no
significance.
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
The
.Fn cos ,
.Fn cosf ,
and
.Fn cosl
functions return the cosine value.
.Sh SEE ALSO
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
.Xr ccos 3 ,
.Xr cosh 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Sh STANDARDS
These functions conform to
.St -isoC-99 .

69
man/cosh.3 Normal file
View file

@ -0,0 +1,69 @@
.\" Copyright (c) 1989, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)cosh.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/cosh.3,v 1.14 2011/10/17 05:41:03 das Exp $
.\"
.Dd January 14, 2005
.Dt COSH 3
.Os
.Sh NAME
.Nm cosh ,
.Nm coshf
.Nd hyperbolic cosine functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn cosh "double x"
.Ft float
.Fn coshf "float x"
.Sh DESCRIPTION
The
.Fn cosh
and the
.Fn coshf
functions compute the hyperbolic cosine of
.Fa x .
.Sh SEE ALSO
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
.Xr ccosh 3 ,
.Xr cos 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Sh STANDARDS
The
.Fn cosh
function conforms to
.St -isoC .

102
man/csqrt.3 Normal file
View file

@ -0,0 +1,102 @@
.\" Copyright (c) 2007-2008 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/csqrt.3,v 1.2 2008/03/30 20:07:15 das Exp $
.\"
.Dd March 30, 2008
.Dt CSQRT 3
.Os
.Sh NAME
.Nm csqrt ,
.Nm csqrtf ,
.Nm csqrtl
.Nd complex square root functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In complex.h
.Ft double complex
.Fn csqrt "double complex z"
.Ft float complex
.Fn csqrtf "float complex z"
.Ft long double complex
.Fn csqrtl "long double complex z"
.Sh DESCRIPTION
The
.Fn csqrt ,
.Fn csqrtf ,
and
.Fn csqrtl
functions compute the square root of
.Fa z
in the complex plane, with a branch cut along the negative real axis.
In other words,
.Fn csqrt ,
.Fn csqrtf ,
and
.Fn csqrtl
always return the square root whose real part is non-negative.
.Sh RETURN VALUES
These functions return the requested square root.
The square root of 0 is
.Li +0 \*(Pm 0 ,
where the imaginary parts of the input and respective result have
the same sign.
For infinities and \*(Nas, the following rules apply, with the
earlier rules having precedence:
.Bl -column -offset indent "-\*(If + \*(Na*I" "\*(If \*(Pm \*(If*I " "(for all k)"
.Em Input Result
k + \*(If*I \*(If + \*(If*I (for all k)
-\*(If + \*(Na*I \*(Na \*(Pm \*(If*I
\*(If + \*(Na*I \*(If + \*(Na*I
k + \*(Na*I \*(Na + \*(Na*I
\*(Na + k*I \*(Na + \*(Na*I
-\*(If + k*I +0 + \*(If*I
\*(If + k*I \*(If + 0*I
.El
.Pp
For numbers with negative imaginary parts, the above special cases
apply given the identity:
.Dl csqrt(conj(z) = conj(sqrt(z))
Note that the sign of \*(Na is indeterminate.
Also, if the real or imaginary part of the input is finite and
an \*(Na is generated, an invalid exception will be thrown.
.Sh SEE ALSO
.Xr cabs 3 ,
.Xr fenv 3 ,
.Xr math 3 ,
.Sh STANDARDS
The
.Fn csqrt ,
.Fn csqrtf ,
and
.Fn csqrtl
functions conform to
.St -isoC-99 .
.Sh BUGS
For
.Fn csqrt
and
.Fn csqrtl ,
inexact results are not always correctly rounded.

93
man/erf.3 Normal file
View file

@ -0,0 +1,93 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)erf.3 6.4 (Berkeley) 4/20/91
.\" $FreeBSD: src/lib/msun/man/erf.3,v 1.12 2007/01/09 01:02:05 imp Exp $
.\"
.Dd April 20, 1991
.Dt ERF 3
.Os
.Sh NAME
.Nm erf ,
.Nm erff ,
.Nm erfc ,
.Nm erfcf
.Nd error function operators
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn erf "double x"
.Ft float
.Fn erff "float x"
.Ft double
.Fn erfc "double x"
.Ft float
.Fn erfcf "float x"
.Sh DESCRIPTION
These functions calculate the error function of
.Fa x .
.Pp
The
.Fn erf
and the
.Fn erff
functions calculate the error function of x; where
.Bd -ragged -offset indent
.if n \{\
erf(x) = 2/sqrt(pi)\(**\|integral from 0 to x of exp(\-t\(**t) dt.
\}
.if t \{\
erf\|(x) :=
(2/\(sr\(*p)\|\(is\d\s8\z0\s10\u\u\s8x\s10\d\|exp(\-t\u\s82\s10\d)\|dt.
\}
.Ed
.Pp
The
.Fn erfc
and the
.Fn erfcf
functions calculate the complementary error function of
.Fa x ;
that is
.Fn erfc
subtracts the result of the error function
.Fn erf x
from 1.0.
This is useful, since for large
.Fa x
places disappear.
.Sh SEE ALSO
.Xr math 3
.Sh HISTORY
The
.Fn erf
and
.Fn erfc
functions appeared in
.Bx 4.3 .

177
man/exp.3 Normal file
View file

@ -0,0 +1,177 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)exp.3 6.12 (Berkeley) 7/31/91
.\" $FreeBSD: src/lib/msun/man/exp.3,v 1.24 2008/01/18 21:43:00 das Exp $
.\"
.Dd January 17, 2008
.Dt EXP 3
.Os
.Sh NAME
.Nm exp ,
.Nm expf ,
.\" The sorting error is intentional. exp and expf should be adjacent.
.Nm exp2 ,
.Nm exp2f ,
.Nm exp2l ,
.Nm expm1 ,
.Nm expm1f ,
.Nm pow ,
.Nm powf
.Nd exponential and power functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn exp "double x"
.Ft float
.Fn expf "float x"
.Ft double
.Fn exp2 "double x"
.Ft float
.Fn exp2f "float x"
.Ft long double
.Fn exp2l "long double x"
.Ft double
.Fn expm1 "double x"
.Ft float
.Fn expm1f "float x"
.Ft double
.Fn pow "double x" "double y"
.Ft float
.Fn powf "float x" "float y"
.Sh DESCRIPTION
The
.Fn exp
and the
.Fn expf
functions compute the base
.Ms e
exponential value of the given argument
.Fa x .
.Pp
The
.Fn exp2 ,
.Fn exp2f ,
and
.Fn exp2l
functions compute the base 2 exponential of the given argument
.Fa x .
.Pp
The
.Fn expm1
and the
.Fn expm1f
functions compute the value exp(x)\-1 accurately even for tiny argument
.Fa x .
.Pp
The
.Fn pow
and the
.Fn powf
functions compute the value
of
.Ar x
to the exponent
.Ar y .
.Sh ERROR (due to Roundoff etc.)
The values of
.Fn exp 0 ,
.Fn expm1 0 ,
.Fn exp2 integer ,
and
.Fn pow integer integer
are exact provided that they are representable.
.\" XXX Is this really true for pow()?
Otherwise the error in these functions is generally below one
.Em ulp .
.Sh RETURN VALUES
These functions will return the appropriate computation unless an error
occurs or an argument is out of range.
The functions
.Fn pow x y
and
.Fn powf x y
raise an invalid exception and return an \*(Na if
.Fa x
< 0 and
.Fa y
is not an integer.
.Sh NOTES
The function
.Fn pow x 0
returns x**0 = 1 for all x including x = 0, \*(If, and \*(Na .
Previous implementations of pow may
have defined x**0 to be undefined in some or all of these
cases.
Here are reasons for returning x**0 = 1 always:
.Bl -enum -width indent
.It
Any program that already tests whether x is zero (or
infinite or \*(Na) before computing x**0 cannot care
whether 0**0 = 1 or not.
Any program that depends
upon 0**0 to be invalid is dubious anyway since that
expression's meaning and, if invalid, its consequences
vary from one computer system to another.
.It
Some Algebra texts (e.g.\& Sigler's) define x**0 = 1 for
all x, including x = 0.
This is compatible with the convention that accepts a[0]
as the value of polynomial
.Bd -literal -offset indent
p(x) = a[0]\(**x**0 + a[1]\(**x**1 + a[2]\(**x**2 +...+ a[n]\(**x**n
.Ed
.Pp
at x = 0 rather than reject a[0]\(**0**0 as invalid.
.It
Analysts will accept 0**0 = 1 despite that x**y can
approach anything or nothing as x and y approach 0
independently.
The reason for setting 0**0 = 1 anyway is this:
.Bd -ragged -offset indent
If x(z) and y(z) are
.Em any
functions analytic (expandable
in power series) in z around z = 0, and if there
x(0) = y(0) = 0, then x(z)**y(z) \(-> 1 as z \(-> 0.
.Ed
.It
If 0**0 = 1, then
\*(If**0 = 1/0**0 = 1 too; and
then \*(Na**0 = 1 too because x**0 = 1 for all finite
and infinite x, i.e., independently of x.
.El
.Sh SEE ALSO
.Xr fenv 3 ,
.Xr ldexp 3 ,
.Xr log 3 ,
.Xr math 3
.Sh STANDARDS
These functions conform to
.St -isoC-99 .

83
man/fabs.3 Normal file
View file

@ -0,0 +1,83 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" @(#)fabs.3 5.1 (Berkeley) 5/2/91
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)fabs.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/fabs.3,v 1.12 2007/01/09 01:02:05 imp Exp $
.\"
.Dd October 25, 2003
.Dt FABS 3
.Os
.Sh NAME
.Nm fabs ,
.Nm fabsf ,
.Nm fabsl
.Nd floating-point absolute value functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn fabs "double x"
.Ft float
.Fn fabsf "float x"
.Ft long double
.Fn fabsl "long double x"
.Sh DESCRIPTION
The
.Fn fabs ,
.Fn fabsf
and
.Fn fabsl
functions compute the absolute value of a floating-point number
.Fa x .
.Sh RETURN VALUES
The
.Fn fabs ,
.Fn fabsf
and
.Fn fabsl
functions return the absolute value of
.Fa x .
.Sh SEE ALSO
.Xr abs 3 ,
.Xr ceil 3 ,
.Xr floor 3 ,
.Xr ieee 3 ,
.Xr math 3 ,
.Xr rint 3
.Sh STANDARDS
The
.Fn fabs
function conforms to
.St -isoC .
The
.Fn fabsf
and
.Fn fabsl
functions conform to
.St -isoC-99 .

86
man/fdim.3 Normal file
View file

@ -0,0 +1,86 @@
.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/fdim.3,v 1.2 2010/08/16 15:18:30 joel Exp $
.\"
.Dd June 29, 2004
.Dt FDIM 3
.Os
.Sh NAME
.Nm fdim ,
.Nm fdimf ,
.Nm fdiml
.Nd positive difference functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn fdim "double x" "double y"
.Ft float
.Fn fdimf "float x" "float y"
.Ft long double
.Fn fdiml "long double x" "long double y"
.Sh DESCRIPTION
The
.Fn fdim ,
.Fn fdimf ,
and
.Fn fdiml
functions return the positive difference between
.Fa x
and
.Fa y .
That is, if
.Fa x\- Ns Fa y
is positive, then
.Fa x\- Ns Fa y
is returned.
If either
.Fa x
or
.Fa y
is an \*(Na, then an \*(Na is returned.
Otherwise, the result is
.Li +0.0 .
.Pp
Overflow or underflow may occur if the exact result is not
representable in the return type.
No other exceptions are raised.
.Sh SEE ALSO
.Xr fabs 3 ,
.Xr fmax 3 ,
.Xr fmin 3 ,
.Xr math 3
.Sh STANDARDS
The
.Fn fdim ,
.Fn fdimf ,
and
.Fn fdiml
functions conform to
.St -isoC-99 .
.Sh HISTORY
These routines first appeared in
.Fx 5.3 .

139
man/feclearexcept.3 Normal file
View file

@ -0,0 +1,139 @@
.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/feclearexcept.3,v 1.3 2005/01/14 09:12:05 ru Exp $
.\"
.Dd May 8, 2004
.Dt FECLEAREXCEPT 3
.Os
.Sh NAME
.Nm feclearexcept ,
.Nm fegetexceptflag ,
.Nm feraiseexcept ,
.Nm fesetexceptflag ,
.Nm fetestexcept
.Nd floating-point exception flag manipulation
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In fenv.h
.Fd "#pragma STDC FENV_ACCESS ON"
.Ft int
.Fn feclearexcept "int excepts"
.Ft int
.Fn fegetexceptflag "fexcept_t *flagp" "int excepts"
.Ft int
.Fn feraiseexcept "int excepts"
.Ft int
.Fn fesetexceptflag "const fexcept_t *flagp" "int excepts"
.Ft int
.Fn fetestexcept "int excepts"
.Sh DESCRIPTION
The
.Fn feclearexcept
routine clears the floating-point exception flags specified by
.Fa excepts ,
whereas
.Fn feraiseexcept
raises the specified exceptions.
Raising an exception causes the corresponding flag to be set,
and a
.Dv SIGFPE
is delivered to the process if the exception is unmasked.
.Pp
The
.Fn fetestexcept
function determines which flags are currently set, of those specified by
.Fa excepts .
.Pp
The
.Fn fegetexceptflag
function stores the state of the exception flags specified in
.Fa excepts
in the opaque object pointed to by
.Fa flagp .
Similarly,
.Fn fesetexceptflag
changes the specified exception flags to reflect the state stored in
the object pointed to by
.Fa flagp .
Note that the flags restored with
.Fn fesetexceptflag
must be a (not necessarily proper) subset of the flags recorded by
a prior call to
.Fn fegetexceptflag .
.Pp
For all of these functions, the possible types of exceptions
include those described in
.Xr fenv 3 .
Some architectures may define other types of floating-point exceptions.
.Sh IMPLEMENTATION NOTES
On some architectures, raising an overflow or underflow exception
also causes an inexact exception to be raised.
In these cases, the overflow or underflow will be raised first.
.Pp
The
.Fn fegetexceptflag
and
.Fn fesetexceptflag
routines are preferred to
.Fn fetestexcept
and
.Fn feraiseexcept ,
respectively, for saving and restoring exception flags.
The latter do not re-raise exceptions and may preserve
architecture-specific information such as addresses where
exceptions occurred.
.Sh RETURN VALUES
The
.Fn feclearexcept ,
.Fn fegetexceptflag ,
.Fn feraiseexcept ,
and
.Fn fesetexceptflag
functions return 0 upon success, and non-zero otherwise.
The
.Fn fetestexcept
function returns the bitwise OR of the values of the current exception
flags that were requested.
.Sh SEE ALSO
.Xr sigaction 2 ,
.Xr feholdexcept 3 ,
.Xr fenv 3 ,
.Xr feupdateenv 3 ,
.Xr fpgetsticky 3 ,
.Xr fpresetsticky 3
.Sh STANDARDS
The
.Fn feclearexcept ,
.Fn fegetexceptflag ,
.Fn feraiseexcept ,
.Fn fesetexceptflag ,
and
.Fn fetestexcept
routines conform to
.St -isoC-99 .
.Sh HISTORY
These functions first appeared in
.Fx 5.3 .

98
man/feenableexcept.3 Normal file
View file

@ -0,0 +1,98 @@
.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/feenableexcept.3,v 1.1 2005/03/16 19:04:28 das Exp $
.\"
.Dd March 16, 2005
.Dt FEENABLEEXCEPT 3
.Os
.Sh NAME
.Nm feenableexcept ,
.Nm fedisableexcept ,
.Nm fegetexcept
.Nd floating-point exception masking
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In fenv.h
.Fd "#pragma STDC FENV_ACCESS ON"
.Ft int
.Fn feenableexcept "int excepts"
.Ft int
.Fn fedisableexcept "int excepts"
.Ft int
.Fn fegetexcept "void"
.Sh DESCRIPTION
The
.Fn feenableexcept
and
.Fn fedisableexcept
functions
unmask and mask (respectively) exceptions specified in
.Fa excepts .
The
.Fn fegetexcept
function
returns the current exception mask.
All exceptions are masked by default.
.Pp
Floating-point operations that produce unmasked exceptions will trap, and a
.Dv SIGFPE
will be delivered to the process.
By installing a signal handler for
.Dv SIGFPE ,
applications can take appropriate action immediately without
testing the exception flags after every operation.
Note that the trap may not be immediate, but it should occur
before the next floating-point instruction is executed.
.Pp
For all of these functions, the possible types of exceptions
include those described in
.Xr fenv 3 .
Some architectures may define other types of floating-point exceptions.
.Sh RETURN VALUES
The
.Fn feenableexcept ,
.Fn fedisableexcept ,
and
.Fn fegetexcept
functions return a bitmap of the exceptions that were unmasked
prior to the call.
.Sh SEE ALSO
.Xr sigaction 2 ,
.Xr feclearexcept 3 ,
.Xr feholdexcept 3 ,
.Xr fenv 3 ,
.Xr feupdateenv 3
.Sh BUGS
Functions in the standard library may trigger exceptions multiple
times as a result of intermediate computations;
however, they generally do not trigger spurious exceptions.
.Pp
No interface is provided to permit exceptions to be handled in
nontrivial ways.
There is no uniform way for an exception handler to access
information about the exception-causing instruction, or
to determine whether that instruction should be reexecuted
after returning from the handler.

113
man/fegetenv.3 Normal file
View file

@ -0,0 +1,113 @@
.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/fegetenv.3,v 1.1 2004/06/06 10:06:26 das Exp $
.\"
.Dd May 8, 2004
.Dt FEGETENV 3
.Os
.Sh NAME
.Nm fegetenv ,
.Nm feholdexcept ,
.Nm fesetenv ,
.Nm feupdateenv
.Nd floating-point environment save and restore
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In fenv.h
.Fd "#pragma STDC FENV_ACCESS ON"
.Ft int
.Fn fegetenv "fenv_t *envp"
.Ft int
.Fn feholdexcept "fenv_t *envp"
.Ft int
.Fn fesetenv "const fenv_t *envp"
.Ft int
.Fn feupdateenv "const fenv_t *envp"
.Sh DESCRIPTION
The floating-point environment includes exception flags and masks, the
current rounding mode, and other architecture-specific settings.
However, it does not include the floating-point register file.
.Pp
The
.Fn fegetenv
function stores the current floating-point environment in the object
pointed to by
.Fa envp ,
whereas
.Fn feholdexcept
saves the current environment, then clears all exception flags
and masks all floating-point exceptions.
.Pp
The
.Fn fesetenv
function restores a previously saved environment.
The
.Fn feupdateenv
function restores a saved environment as well, but it also
raises any exceptions that were set in the environment it
replaces.
.Pp
The
.Fn feholdexcept
function is often used with
.Fn feupdateenv
or
.Fn fesetenv
to suppress spurious exceptions that occur as a result of
intermediate computations.
An example in
.Xr fenv 3
demonstrates how to do this.
.Sh RETURN VALUES
The
.Fn fegetenv ,
.Fn feholdexcept ,
.Fn fesetenv ,
and
.Fn feupdateenv
functions return 0 if they succeed, and non-zero otherwise.
.Sh SEE ALSO
.Xr feclearexcept 3 ,
.Xr fenv 3 ,
.Xr feraiseexcept 3 ,
.Xr fesetenv 3 ,
.Xr fetestexcept 3 ,
.Xr fpgetmask 3 ,
.Xr fpgetprec 3 ,
.Xr fpsetmask 3 ,
.Xr fpsetprec 3
.Sh STANDARDS
The
.Fn fegetenv ,
.Fn feholdexcept ,
.Fn fesetenv ,
and
.Fn feupdateenv
functions conform to
.St -isoC-99 .
.Sh HISTORY
These routines first appeared in
.Fx 5.3 .

83
man/fegetround.3 Normal file
View file

@ -0,0 +1,83 @@
.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/fegetround.3,v 1.2 2005/01/14 09:12:05 ru Exp $
.\"
.Dd May 8, 2004
.Dt FEGETROUND 3
.Os
.Sh NAME
.Nm fegetround ,
.Nm fesetround
.Nd floating-point rounding control
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In fenv.h
.Fd "#pragma STDC FENV_ACCESS ON"
.Ft int
.Fn fegetround void
.Ft int
.Fn fesetround "int round"
.Sh DESCRIPTION
The
.Fn fegetround
function determines the current floating-point rounding mode,
and the
.Fn fesetround
function sets the current rounding mode to
.Fa round .
The rounding mode is one of
.Dv FE_TONEAREST , FE_DOWNWARD , FE_UPWARD ,
or
.Dv FE_TOWARDZERO ,
as described in
.Xr fenv 3 .
.Sh RETURN VALUES
The
.Fn fegetround
routine returns the current rounding mode.
The
.Fn fesetround
function returns 0 on success and non-zero otherwise;
however, the present implementation always succeeds.
.Sh SEE ALSO
.Xr fenv 3 ,
.Xr fpgetround 3 ,
.Xr fpsetround 3
.Sh STANDARDS
The
.Fn fegetround
and
.Fn fesetround
functions conform to
.St -isoC-99 .
.Sh HISTORY
These routines first appeared in
.Fx 5.3 .
They supersede the non-standard
.Xr fpgetround 3
and
.Xr fpsetround 3
functions.

293
man/fenv.3 Normal file
View file

@ -0,0 +1,293 @@
.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/fenv.3,v 1.8 2011/10/21 14:23:59 das Exp $
.\"
.Dd March 16, 2005
.Dt FENV 3
.Os
.Sh NAME
.Nm feclearexcept ,
.Nm fegetexceptflag ,
.Nm feraiseexcept ,
.Nm fesetexceptflag ,
.Nm fetestexcept ,
.Nm fegetround ,
.Nm fesetround ,
.Nm fegetenv ,
.Nm feholdexcept ,
.Nm fesetenv ,
.Nm feupdateenv ,
.Nm feenableexcept ,
.Nm fedisableexcept ,
.Nm fegetexcept
.Nd floating-point environment control
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In fenv.h
.Fd "#pragma STDC FENV_ACCESS ON"
.Ft int
.Fn feclearexcept "int excepts"
.Ft int
.Fn fegetexceptflag "fexcept_t *flagp" "int excepts"
.Ft int
.Fn feraiseexcept "int excepts"
.Ft int
.Fn fesetexceptflag "const fexcept_t *flagp" "int excepts"
.Ft int
.Fn fetestexcept "int excepts"
.Ft int
.Fn fegetround void
.Ft int
.Fn fesetround "int round"
.Ft int
.Fn fegetenv "fenv_t *envp"
.Ft int
.Fn feholdexcept "fenv_t *envp"
.Ft int
.Fn fesetenv "const fenv_t *envp"
.Ft int
.Fn feupdateenv "const fenv_t *envp"
.Ft int
.Fn feenableexcept "int excepts"
.Ft int
.Fn fedisableexcept "int excepts"
.Ft int
.Fn fegetexcept void
.Sh DESCRIPTION
The
.In fenv.h
routines manipulate the floating-point environment,
which includes the exception flags and rounding modes defined in
.St -ieee754 .
.Ss Exceptions
Exception flags are set as side-effects of floating-point arithmetic
operations and math library routines, and they remain set until
explicitly cleared.
The following macros expand to bit flags of type
.Vt int
representing the five standard floating-point exceptions.
.Bl -tag -width ".Dv FE_DIVBYZERO"
.It Dv FE_DIVBYZERO
A divide-by-zero exception occurs when the
.Em exact
result of a computation is infinite (according to the limit definition).
For example, dividing a finite non-zero number by zero or computing
.Fn log 0
raises a divide-by-zero exception.
.It Dv FE_INEXACT
An inexact exception is raised whenever there is a loss of accuracy
due to rounding.
.It Dv FE_INVALID
Invalid operation exceptions occur when a program attempts to
perform calculations for which there is no reasonable representable
answer.
For instance, subtraction of like-signed infinities, division of zero by zero,
ordered comparison involving \*(Nas, and taking the real square root of a
negative number are all invalid operations.
.It Dv FE_OVERFLOW
In contrast with divide-by-zero,
an overflow exception occurs when an infinity is produced because
the magnitude of the exact result is
.Em finite
but too large to fit in the destination type.
For example, computing
.Li DBL_MAX * 2
raises an overflow exception.
.It Dv FE_UNDERFLOW
Underflow occurs when the result of a computation loses precision
because it is too close to zero.
The result is a subnormal number or zero.
.El
.Pp
Additionally, the
.Dv FE_ALL_EXCEPT
macro expands to the bitwise OR of the above flags and any
architecture-specific flags.
Combinations of these flags are passed to the
.Fn feclearexcept ,
.Fn fegetexceptflag ,
.Fn feraiseexcept ,
.Fn fesetexceptflag ,
and
.Fn fetestexcept
functions to clear, save, raise, restore, and examine the
processor's floating-point exception flags, respectively.
.Pp
Exceptions may be
.Em unmasked
with
.Fn feenableexcept
and masked with
.Fn fedisableexcept .
Unmasked exceptions cause a trap when they are produced, and
all exceptions are masked by default.
The current mask can be tested with
.Fn fegetexcept .
.Ss Rounding Modes
.St -ieee754
specifies four rounding modes.
These modes control the direction in which results are rounded
from their exact values in order to fit them into binary
floating-point variables.
The four modes correspond with the following symbolic constants.
.Bl -tag -width ".Dv FE_TOWARDZERO"
.It Dv FE_TONEAREST
Results are rounded to the closest representable value.
If the exact result is exactly half way between two representable
values, the value whose last binary digit is even (zero) is chosen.
This is the default mode.
.It Dv FE_DOWNWARD
Results are rounded towards negative \*[If].
.It Dv FE_UPWARD
Results are rounded towards positive \*[If].
.It Dv FE_TOWARDZERO
Results are rounded towards zero.
.El
.Pp
The
.Fn fegetround
and
.Fn fesetround
functions query and set the rounding mode.
.Ss Environment Control
The
.Fn fegetenv
and
.Fn fesetenv
functions save and restore the floating-point environment,
which includes exception flags, the current exception mask,
the rounding mode, and possibly other implementation-specific
state.
The
.Fn feholdexcept
function behaves like
.Fn fegetenv ,
but with the additional effect of clearing the exception flags and
installing a
.Em non-stop
mode.
In non-stop mode, floating-point operations will set exception flags
as usual, but no
.Dv SIGFPE
signals will be generated as a result.
Non-stop mode is the default, but it may be altered by
.Fn feenableexcept
and
.Fn fedisableexcept .
The
.Fn feupdateenv
function restores a saved environment similarly to
.Fn fesetenv ,
but it also re-raises any floating-point exceptions from the old
environment.
.Pp
The macro
.Dv FE_DFL_ENV
expands to a pointer to the default environment.
.Sh EXAMPLES
The following routine computes the square root function.
It explicitly raises an invalid exception on appropriate inputs using
.Fn feraiseexcept .
It also defers inexact exceptions while it computes intermediate
values, and then it allows an inexact exception to be raised only if
the final answer is inexact.
.Bd -literal -offset indent
#pragma STDC FENV_ACCESS ON
double sqrt(double n) {
double x = 1.0;
fenv_t env;
if (isnan(n) || n < 0.0) {
feraiseexcept(FE_INVALID);
return (NAN);
}
if (isinf(n) || n == 0.0)
return (n);
feholdexcept(&env);
while (fabs((x * x) - n) > DBL_EPSILON * 2 * x)
x = (x / 2) + (n / (2 * x));
if (x * x == n)
feclearexcept(FE_INEXACT);
feupdateenv(&env);
return (x);
}
.Ed
.Sh SEE ALSO
.Xr cc 1 ,
.Xr feclearexcept 3 ,
.Xr fedisableexcept 3 ,
.Xr feenableexcept 3 ,
.Xr fegetenv 3 ,
.Xr fegetexcept 3 ,
.Xr fegetexceptflag 3 ,
.Xr fegetround 3 ,
.Xr feholdexcept 3 ,
.Xr feraiseexcept 3 ,
.Xr fesetenv 3 ,
.Xr fesetexceptflag 3 ,
.Xr fesetround 3 ,
.Xr fetestexcept 3 ,
.Xr feupdateenv 3 ,
.Xr fpgetprec 3 ,
.Xr fpsetprec 3
.Sh STANDARDS
Except as noted below,
.In fenv.h
conforms to
.St -isoC-99 .
The
.Fn feenableexcept ,
.Fn fedisableexcept ,
and
.Fn fegetexcept
routines are extensions.
.Sh HISTORY
The
.In fenv.h
header first appeared in
.Fx 5.3 .
It supersedes the non-standard routines defined in
.In ieeefp.h
and documented in
.Xr fpgetround 3 .
.Sh CAVEATS
The FENV_ACCESS pragma can be enabled with
.Dl "#pragma STDC FENV_ACCESS ON"
and disabled with the
.Dl "#pragma STDC FENV_ACCESS OFF"
directive.
This lexically-scoped annotation tells the compiler that the program
may access the floating-point environment, so optimizations that would
violate strict IEEE-754 semantics are disabled.
If execution reaches a block of code for which
.Dv FENV_ACCESS
is off, the floating-point environment will become undefined.
.Sh BUGS
The
.Dv FENV_ACCESS
pragma is unimplemented in the system compiler.
However, non-constant expressions generally produce the correct
side-effects at low optimization levels.

78
man/floor.3 Normal file
View file

@ -0,0 +1,78 @@
.\" Copyright (c) 1985, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)floor.3 6.5 (Berkeley) 4/19/91
.\" $FreeBSD: src/lib/msun/man/floor.3,v 1.18 2007/01/09 01:02:06 imp Exp $
.\"
.Dd January 13, 2005
.Dt FLOOR 3
.Os
.Sh NAME
.Nm floor ,
.Nm floorf ,
.Nm floorl
.Nd largest integral value less than or equal to x
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn floor "double x"
.Ft float
.Fn floorf "float x"
.Ft "long double"
.Fn floorl "long double x"
.Sh DESCRIPTION
The
.Fn floor ,
.Fn floorf
and
.Fn floorl
functions return the largest integral value
less than or equal to
.Fa x ,
expressed as a floating-point number.
.Sh SEE ALSO
.Xr abs 3 ,
.Xr ceil 3 ,
.Xr fabs 3 ,
.Xr ieee 3 ,
.Xr math 3 ,
.Xr rint 3 ,
.Xr round 3 ,
.Xr trunc 3
.Sh STANDARDS
The
.Fn floor
function conforms to
.St -isoC .
The
.Fn floorf
and
.Fn floorl
functions conform to
.St -isoC-99 .

116
man/fma.3 Normal file
View file

@ -0,0 +1,116 @@
.\" Copyright (c) 2005 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/fma.3,v 1.3 2005/11/24 09:25:10 joel Exp $
.\"
.Dd January 22, 2005
.Dt FMA 3
.Os
.Sh NAME
.Nm fma ,
.Nm fmaf ,
.Nm fmal
.Nd fused multiply-add
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn fma "double x" "double y" "double z"
.Ft float
.Fn fmaf "float x" "float y" "float z"
.Ft long double
.Fn fmal "long double x" "long double y" "long double z"
.Sh DESCRIPTION
The
.Fn fma ,
.Fn fmaf ,
and
.Fn fmal
functions return
.No "(x * y) + z" ,
computed with only one rounding error.
Using the ordinary multiplication and addition operators, by contrast,
results in two roundings: one for the intermediate product and one for
the final result.
.Pp
For instance, the expression
.No "1.2e100 * 2.0e208 - 1.4e308"
produces \*(If due to overflow in the intermediate product, whereas
.No "fma(1.2e100, 2.0e208, -1.4e308)"
returns approximately 1.0e308.
.Pp
The fused multiply-add operation is often used to improve the
accuracy of calculations such as dot products.
It may also be used to improve performance on machines that implement
it natively.
The macros
.Dv FP_FAST_FMA ,
.Dv FP_FAST_FMAF
and
.Dv FP_FAST_FMAL
may be defined in
.In math.h
to indicate that
.Fn fma ,
.Fn fmaf ,
and
.Fn fmal
(respectively) have comparable or faster speed than a multiply
operation followed by an add operation.
.Sh IMPLEMENTATION NOTES
In general, these routines will behave as one would expect if
.No "x * y + z"
were computed with unbounded precision and range,
then rounded to the precision of the return type.
However, on some platforms, if
.Fa z
is \*(Na, these functions may not raise an exception even
when the computation of
.No "x * y"
would have otherwise generated an invalid exception.
.Sh SEE ALSO
.Xr fenv 3 ,
.Xr math 3
.Sh STANDARDS
The
.Fn fma ,
.Fn fmaf ,
and
.Fn fmal
functions conform to
.St -isoC-99 .
A fused multiply-add operation with virtually identical
characteristics appears in IEEE draft standard 754R.
.Sh HISTORY
The
.Fn fma
and
.Fn fmaf
routines first appeared in
.Fx 5.4 ,
and
.Fn fmal
appeared in
.Fx 6.0 .

97
man/fmax.3 Normal file
View file

@ -0,0 +1,97 @@
.\" Copyright (c) 2004 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/fmax.3,v 1.2 2005/01/14 09:12:05 ru Exp $
.\"
.Dd June 29, 2004
.Dt FMAX 3
.Os
.Sh NAME
.Nm fmax ,
.Nm fmaxf ,
.Nm fmaxl ,
.Nm fmin ,
.Nm fminf ,
.Nm fminl
.Nd floating-point maximum and minimum functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn fmax "double x" "double y"
.Ft float
.Fn fmaxf "float x" "float y"
.Ft "long double"
.Fn fmaxl "long double x" "long double y"
.Ft double
.Fn fmin "double x" "double y"
.Ft float
.Fn fminf "float x" "float y"
.Ft "long double"
.Fn fminl "long double x" "long double y"
.Sh DESCRIPTION
The
.Fn fmax ,
.Fn fmaxf ,
and
.Fn fmaxl
functions return the larger of
.Fa x
and
.Fa y ,
and likewise, the
.Fn fmin ,
.Fn fminf ,
and
.Fn fminl
functions return the smaller of
.Fa x
and
.Fa y .
They treat
.Li +0.0
as being larger than
.Li -0.0 .
If one argument is an \*(Na, then the other argument is returned.
If both arguments are \*(Nas, then the result is an \*(Na.
These routines do not raise any floating-point exceptions.
.Sh SEE ALSO
.Xr fabs 3 ,
.Xr fdim 3 ,
.Xr math 3
.Sh STANDARDS
The
.Fn fmax ,
.Fn fmaxf ,
.Fn fmaxl ,
.Fn fmin ,
.Fn fminf ,
and
.Fn fminl
functions conform to
.St -isoC-99 .
.Sh HISTORY
These routines first appeared in
.Fx 5.3 .

87
man/fmod.3 Normal file
View file

@ -0,0 +1,87 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)fmod.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/fmod.3,v 1.10 2008/06/19 22:39:53 das Exp $
.\"
.Dd June 19, 2008
.Dt FMOD 3
.Os
.Sh NAME
.Nm fmod ,
.Nm fmodf ,
.Nm fmodl
.Nd floating-point remainder functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn fmod "double x" "double y"
.Ft float
.Fn fmodf "float x" "float y"
.Ft long double
.Fn fmodl "long double x" "long double y"
.Sh DESCRIPTION
The
.Fn fmod ,
.Fn fmodf ,
and
.Fn fmodl
functions compute the floating-point remainder of
.Fa x Ns / Fa y .
.Sh RETURN VALUES
If
.Fa y
is non-zero, the
.Fn fmod ,
.Fn fmodf ,
and
.Fn fmodl
functions return the value
.Sm off
.Fa x - Em i * Fa y ,
.Sm on
for some integer
.Em i ,
such that the result has the same sign as
.Fa x
and magnitude less than the magnitude of
.Fa y .
If
.Fa y
is zero, a \*(Na is produced.
.Sh SEE ALSO
.Xr math 3
.Sh STANDARDS
The
.Fn fmod ,
.Fn fmodf ,
and
.Fn fmodl
functions conform to
.St -isoC-99 .

145
man/hypot.3 Normal file
View file

@ -0,0 +1,145 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)hypot.3 6.7 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/hypot.3,v 1.18 2010/05/13 12:08:11 uqs Exp $
.\"
.Dd March 30, 2008
.Dt HYPOT 3
.Os
.Sh NAME
.Nm hypot ,
.Nm hypotf ,
.Nm hypotl ,
.Nm cabs ,
.Nm cabsf ,
.Nm cabsl
.Nd Euclidean distance and complex absolute value functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn hypot "double x" "double y"
.Ft float
.Fn hypotf "float x" "float y"
.Ft "long double"
.Fn hypotl "long double x" "long double y"
.In complex.h
.Ft double
.Fn cabs "double complex z"
.Ft float
.Fn cabsf "float complex z"
.Ft "long double"
.Fn cabsl "long double complex z"
.Sh DESCRIPTION
The
.Fn hypot ,
.Fn hypotf
and
.Fn hypotl
functions
compute the
sqrt(x*x+y*y)
in such a way that underflow will not happen, and overflow
occurs only if the final result deserves it.
The
.Fn cabs ,
.Fn cabsf
and
.Fn cabsl
functions compute the complex absolute value of
.Fa z .
.Pp
.Fn hypot "\*(If" "v"
=
.Fn hypot "v" "\*(If"
= +\*(If for all
.Fa v ,
including \*(Na.
.Sh ERROR (due to Roundoff, etc.)
Below 0.97
.Em ulps .
Consequently
.Fn hypot "5.0" "12.0"
= 13.0
exactly;
in general, hypot and cabs return an integer whenever an
integer might be expected.
.Sh NOTES
As might be expected,
.Fn hypot "v" "\*(Na"
and
.Fn hypot "\*(Na" "v"
are \*(Na for all
.Em finite
.Fa v .
But programmers
might be surprised at first to discover that
.Fn hypot "\(+-\*(If" "\*(Na"
= +\*(If.
This is intentional; it happens because
.Fn hypot "\*(If" "v"
= +\*(If
for
.Em all
.Fa v ,
finite or infinite.
Hence
.Fn hypot "\*(If" "v"
is independent of
.Fa v .
Unlike the reserved operand fault on a
.Tn VAX ,
the
.Tn IEEE
\*(Na is designed to
disappear when it turns out to be irrelevant, as it does in
.Fn hypot "\*(If" "\*(Na" .
.Sh SEE ALSO
.Xr carg 3 ,
.Xr math 3 ,
.Xr sqrt 3
.Sh STANDARDS
The
.Fn hypot ,
.Fn hypotf ,
.Fn hypotl ,
.Fn cabs ,
.Fn cabsf ,
and
.Fn cabsl
functions conform to
.St -isoC-99 .
.Sh HISTORY
Both a
.Fn hypot
function and a
.Fn cabs
function
appeared in
.At v7 .

444
man/ieee.3 Normal file
View file

@ -0,0 +1,444 @@
.\" Copyright (c) 1985 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/ieee.3,v 1.25 2011/10/16 14:30:28 eadler Exp $
.\"
.Dd January 26, 2005
.Dt IEEE 3
.Os
.Sh NAME
.Nm ieee
.Nd IEEE standard 754 for floating-point arithmetic
.Sh DESCRIPTION
The IEEE Standard 754 for Binary Floating-Point Arithmetic
defines representations of floating-point numbers and abstract
properties of arithmetic operations relating to precision,
rounding, and exceptional cases, as described below.
.Ss IEEE STANDARD 754 Floating-Point Arithmetic
Radix: Binary.
.Pp
Overflow and underflow:
.Bd -ragged -offset indent -compact
Overflow goes by default to a signed \*(If.
Underflow is
.Em gradual .
.Ed
.Pp
Zero is represented ambiguously as +0 or \-0.
.Bd -ragged -offset indent -compact
Its sign transforms correctly through multiplication or
division, and is preserved by addition of zeros
with like signs; but x\-x yields +0 for every
finite x.
The only operations that reveal zero's
sign are division by zero and
.Fn copysign x \(+-0 .
In particular, comparison (x > y, x \(>= y, etc.)\&
cannot be affected by the sign of zero; but if
finite x = y then \*(If = 1/(x\-y) \(!= \-1/(y\-x) = \-\*(If.
.Ed
.Pp
Infinity is signed.
.Bd -ragged -offset indent -compact
It persists when added to itself
or to any finite number.
Its sign transforms
correctly through multiplication and division, and
(finite)/\(+-\*(If\0=\0\(+-0
(nonzero)/0 = \(+-\*(If.
But
\*(If\-\*(If, \*(If\(**0 and \*(If/\*(If
are, like 0/0 and sqrt(\-3),
invalid operations that produce \*(Na. ...
.Ed
.Pp
Reserved operands (\*(Nas):
.Bd -ragged -offset indent -compact
An \*(Na is
.Em ( N Ns ot Em a N Ns umber ) .
Some \*(Nas, called Signaling \*(Nas, trap any floating-point operation
performed upon them; they are used to mark missing
or uninitialized values, or nonexistent elements
of arrays.
The rest are Quiet \*(Nas; they are
the default results of Invalid Operations, and
propagate through subsequent arithmetic operations.
If x \(!= x then x is \*(Na; every other predicate
(x > y, x = y, x < y, ...) is FALSE if \*(Na is involved.
.Ed
.Pp
Rounding:
.Bd -ragged -offset indent -compact
Every algebraic operation (+, \-, \(**, /,
\(sr)
is rounded by default to within half an
.Em ulp ,
and when the rounding error is exactly half an
.Em ulp
then
the rounded value's least significant bit is zero.
(An
.Em ulp
is one
.Em U Ns nit
in the
.Em L Ns ast
.Em P Ns lace . )
This kind of rounding is usually the best kind,
sometimes provably so; for instance, for every
x = 1.0, 2.0, 3.0, 4.0, ..., 2.0**52, we find
(x/3.0)\(**3.0 == x and (x/10.0)\(**10.0 == x and ...
despite that both the quotients and the products
have been rounded.
Only rounding like IEEE 754 can do that.
But no single kind of rounding can be
proved best for every circumstance, so IEEE 754
provides rounding towards zero or towards
+\*(If or towards \-\*(If
at the programmer's option.
.Ed
.Pp
Exceptions:
.Bd -ragged -offset indent -compact
IEEE 754 recognizes five kinds of floating-point exceptions,
listed below in declining order of probable importance.
.Bl -column -offset indent "Invalid Operation" "Gradual Underflow"
.Em "Exception Default Result"
Invalid Operation \*(Na, or FALSE
Overflow \(+-\*(If
Divide by Zero \(+-\*(If
Underflow Gradual Underflow
Inexact Rounded value
.El
.Pp
NOTE: An Exception is not an Error unless handled
badly.
What makes a class of exceptions exceptional
is that no single default response can be satisfactory
in every instance.
On the other hand, if a default
response will serve most instances satisfactorily,
the unsatisfactory instances cannot justify aborting
computation every time the exception occurs.
.Ed
.Ss Data Formats
Single-precision:
.Bd -ragged -offset indent -compact
Type name:
.Vt float
.Pp
Wordsize: 32 bits.
.Pp
Precision: 24 significant bits,
roughly like 7 significant decimals.
.Bd -ragged -offset indent -compact
If x and x' are consecutive positive single-precision
numbers (they differ by 1
.Em ulp ) ,
then
.Bd -ragged -compact
5.9e\-08 < 0.5**24 < (x'\-x)/x \(<= 0.5**23 < 1.2e\-07.
.Ed
.Ed
.Pp
.Bl -column "XXX" -compact
Range: Overflow threshold = 2.0**128 = 3.4e38
Underflow threshold = 0.5**126 = 1.2e\-38
.El
.Bd -ragged -offset indent -compact
Underflowed results round to the nearest
integer multiple of 0.5**149 = 1.4e\-45.
.Ed
.Ed
.Pp
Double-precision:
.Bd -ragged -offset indent -compact
Type name:
.Vt double
.Bd -ragged -offset indent -compact
On some architectures,
.Vt long double
is the same as
.Vt double .
.Ed
.Pp
Wordsize: 64 bits.
.Pp
Precision: 53 significant bits,
roughly like 16 significant decimals.
.Bd -ragged -offset indent -compact
If x and x' are consecutive positive double-precision
numbers (they differ by 1
.Em ulp ) ,
then
.Bd -ragged -compact
1.1e\-16 < 0.5**53 < (x'\-x)/x \(<= 0.5**52 < 2.3e\-16.
.Ed
.Ed
.Pp
.Bl -column "XXX" -compact
Range: Overflow threshold = 2.0**1024 = 1.8e308
Underflow threshold = 0.5**1022 = 2.2e\-308
.El
.Bd -ragged -offset indent -compact
Underflowed results round to the nearest
integer multiple of 0.5**1074 = 4.9e\-324.
.Ed
.Ed
.Pp
Extended-precision:
.Bd -ragged -offset indent -compact
Type name:
.Vt long double
(when supported by the hardware)
.Pp
Wordsize: 96 bits.
.Pp
Precision: 64 significant bits,
roughly like 19 significant decimals.
.Bd -ragged -offset indent -compact
If x and x' are consecutive positive extended-precision
numbers (they differ by 1
.Em ulp ) ,
then
.Bd -ragged -compact
1.0e\-19 < 0.5**63 < (x'\-x)/x \(<= 0.5**62 < 2.2e\-19.
.Ed
.Ed
.Pp
.Bl -column "XXX" -compact
Range: Overflow threshold = 2.0**16384 = 1.2e4932
Underflow threshold = 0.5**16382 = 3.4e\-4932
.El
.Bd -ragged -offset indent -compact
Underflowed results round to the nearest
integer multiple of 0.5**16445 = 5.7e\-4953.
.Ed
.Ed
.Pp
Quad-extended-precision:
.Bd -ragged -offset indent -compact
Type name:
.Vt long double
(when supported by the hardware)
.Pp
Wordsize: 128 bits.
.Pp
Precision: 113 significant bits,
roughly like 34 significant decimals.
.Bd -ragged -offset indent -compact
If x and x' are consecutive positive quad-extended-precision
numbers (they differ by 1
.Em ulp ) ,
then
.Bd -ragged -compact
9.6e\-35 < 0.5**113 < (x'\-x)/x \(<= 0.5**112 < 2.0e\-34.
.Ed
.Ed
.Pp
.Bl -column "XXX" -compact
Range: Overflow threshold = 2.0**16384 = 1.2e4932
Underflow threshold = 0.5**16382 = 3.4e\-4932
.El
.Bd -ragged -offset indent -compact
Underflowed results round to the nearest
integer multiple of 0.5**16494 = 6.5e\-4966.
.Ed
.Ed
.Ss Additional Information Regarding Exceptions
.Pp
For each kind of floating-point exception, IEEE 754
provides a Flag that is raised each time its exception
is signaled, and stays raised until the program resets
it.
Programs may also test, save and restore a flag.
Thus, IEEE 754 provides three ways by which programs
may cope with exceptions for which the default result
might be unsatisfactory:
.Bl -enum
.It
Test for a condition that might cause an exception
later, and branch to avoid the exception.
.It
Test a flag to see whether an exception has occurred
since the program last reset its flag.
.It
Test a result to see whether it is a value that only
an exception could have produced.
.Pp
CAUTION: The only reliable ways to discover
whether Underflow has occurred are to test whether
products or quotients lie closer to zero than the
underflow threshold, or to test the Underflow
flag.
(Sums and differences cannot underflow in
IEEE 754; if x \(!= y then x\-y is correct to
full precision and certainly nonzero regardless of
how tiny it may be.)
Products and quotients that
underflow gradually can lose accuracy gradually
without vanishing, so comparing them with zero
(as one might on a VAX) will not reveal the loss.
Fortunately, if a gradually underflowed value is
destined to be added to something bigger than the
underflow threshold, as is almost always the case,
digits lost to gradual underflow will not be missed
because they would have been rounded off anyway.
So gradual underflows are usually
.Em provably
ignorable.
The same cannot be said of underflows flushed to 0.
.El
.Pp
At the option of an implementor conforming to IEEE 754,
other ways to cope with exceptions may be provided:
.Bl -enum
.It
ABORT.
This mechanism classifies an exception in
advance as an incident to be handled by means
traditionally associated with error-handling
statements like "ON ERROR GO TO ...".
Different
languages offer different forms of this statement,
but most share the following characteristics:
.Bl -dash
.It
No means is provided to substitute a value for
the offending operation's result and resume
computation from what may be the middle of an
expression.
An exceptional result is abandoned.
.It
In a subprogram that lacks an error-handling
statement, an exception causes the subprogram to
abort within whatever program called it, and so
on back up the chain of calling subprograms until
an error-handling statement is encountered or the
whole task is aborted and memory is dumped.
.El
.It
STOP.
This mechanism, requiring an interactive
debugging environment, is more for the programmer
than the program.
It classifies an exception in
advance as a symptom of a programmer's error; the
exception suspends execution as near as it can to
the offending operation so that the programmer can
look around to see how it happened.
Quite often
the first several exceptions turn out to be quite
unexceptionable, so the programmer ought ideally
to be able to resume execution after each one as if
execution had not been stopped.
.It
\&... Other ways lie beyond the scope of this document.
.El
.Pp
Ideally, each
elementary function should act as if it were indivisible, or
atomic, in the sense that ...
.Bl -enum
.It
No exception should be signaled that is not deserved by
the data supplied to that function.
.It
Any exception signaled should be identified with that
function rather than with one of its subroutines.
.It
The internal behavior of an atomic function should not
be disrupted when a calling program changes from
one to another of the five or so ways of handling
exceptions listed above, although the definition
of the function may be correlated intentionally
with exception handling.
.El
.Pp
The functions in
.Nm libm
are only approximately atomic.
They signal no inappropriate exception except possibly ...
.Bl -tag -width indent -offset indent -compact
.It Xo
Over/Underflow
.Xc
when a result, if properly computed, might have lain barely within range, and
.It Xo
Inexact in
.Fn cabs ,
.Fn cbrt ,
.Fn hypot ,
.Fn log10
and
.Fn pow
.Xc
when it happens to be exact, thanks to fortuitous cancellation of errors.
.El
Otherwise, ...
.Bl -tag -width indent -offset indent -compact
.It Xo
Invalid Operation is signaled only when
.Xc
any result but \*(Na would probably be misleading.
.It Xo
Overflow is signaled only when
.Xc
the exact result would be finite but beyond the overflow threshold.
.It Xo
Divide-by-Zero is signaled only when
.Xc
a function takes exactly infinite values at finite operands.
.It Xo
Underflow is signaled only when
.Xc
the exact result would be nonzero but tinier than the underflow threshold.
.It Xo
Inexact is signaled only when
.Xc
greater range or precision would be needed to represent the exact result.
.El
.Sh SEE ALSO
.Xr fenv 3 ,
.Xr ieee_test 3 ,
.Xr math 3
.Pp
An explanation of IEEE 754 and its proposed extension p854
was published in the IEEE magazine MICRO in August 1984 under
the title "A Proposed Radix- and Word-length-independent
Standard for Floating-point Arithmetic" by
.An "W. J. Cody"
et al.
The manuals for Pascal, C and BASIC on the Apple Macintosh
document the features of IEEE 754 pretty well.
Articles in the IEEE magazine COMPUTER vol.\& 14 no.\& 3 (Mar.\&
1981), and in the ACM SIGNUM Newsletter Special Issue of
Oct.\& 1979, may be helpful although they pertain to
superseded drafts of the standard.
.Sh STANDARDS
.St -ieee754

89
man/ieee_test.3 Normal file
View file

@ -0,0 +1,89 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/ieee_test.3,v 1.14 2007/01/09 01:02:06 imp Exp $
.\"
.Dd November 6, 2005
.Dt IEEE_TEST 3
.Os
.Sh NAME
.Nm scalb ,
.Nm scalbf ,
.Nm significand ,
.Nm significandf
.Nd IEEE test functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn scalb "double x" "double n"
.Ft float
.Fn scalbf "float x" "float n"
.Ft double
.Fn significand "double x"
.Ft float
.Fn significandf "float x"
.Sh DESCRIPTION
These functions allow users to test conformance to
.St -ieee754 .
Their use is not otherwise recommended.
.Pp
.Fn scalb x n
and
.Fn scalbf x n
return
.Fa x Ns \(**(2** Ns Fa n )
computed by exponent manipulation.
If
.Fa n
is not an integer, \*(Pm\*(If, or an \*(Na, the result is unspecified.
.Pp
.Fn significand x
and
.Fn significandf x
return
.Fa sig ,
where
.Fa x
:=
.Fa sig No \(** 2** Ns Fa n
with 1 \(<=
.Fa sig
< 2.
.Fn significand x
and
.Fn significandf x
are not defined when
.Fa x
is 0, \*(Pm\*(If, or \*(Na.
.Sh SEE ALSO
.Xr ieee 3 ,
.Xr math 3
.Sh STANDARDS
.St -ieee754

124
man/ilogb.3 Normal file
View file

@ -0,0 +1,124 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/ilogb.3,v 1.5 2007/12/17 03:53:38 das Exp $
.\"
.Dd December 16, 2007
.Dt ILOGB 3
.Os
.Sh NAME
.Nm ilogb ,
.Nm ilogbf ,
.Nm ilogbl ,
.Nm logb ,
.Nm logbf ,
.Nm logbl
.Nd extract exponent
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft int
.Fn ilogb "double x"
.Ft int
.Fn ilogbf "float x"
.Ft int
.Fn ilogbl "long double x"
.Ft double
.Fn logb "double x"
.Ft float
.Fn logbf "float x"
.Ft long double
.Fn logbl "long double x"
.Sh DESCRIPTION
.Fn ilogb ,
.Fn ilogbf
and
.Fn ilogbl
return
.Fa x Ns 's exponent
in integer format.
.Fn ilogb \*(Pm\*(If
returns
.Dv INT_MAX ,
.Fn ilogb \*(Pm\*(Na
returns
.Dv FP_ILOGBNAN ,
and
.Fn ilogb 0
returns
.Dv FP_ILOGB0 .
.Pp
.Fn logb x ,
.Fn logbf x ,
and
.Fn logbl x
return
.Fa x Ns 's exponent
in floating\-point format with the same precision as
.Fa x .
.Fn logb \*(Pm\*(If
returns +\*(If, and
.Fn logb 0
returns -\*(If with a division by zero exception.
.Sh SEE ALSO
.Xr frexp 3 ,
.Xr ieee 3 ,
.Xr math 3 ,
.Xr scalbn 3
.Sh STANDARDS
The
.Fn ilogb ,
.Fn ilogbf ,
.Fn ilogbl ,
.Fn logb ,
.Fn logbf ,
and
.Fn logbl
routines conform to
.St -isoC-99 .
The latter three
implement the logb function recommended by
.St -ieee754 .
.Sh HISTORY
.Bl -tag -width "Function " -compact
.It Em Function
.Em "First Appeared In"
.It Fn logb
.Bx 4.3
.It Fn ilogb
.Fx 1.1.5
.It Fn ilogbf
.Fx 2.0
.It Fn logbf
.Fx 2.0
.It Fn ilogbl
.Fx 5.4
.It Fn logbl
.Fx 8.0
.El

169
man/j0.3 Normal file
View file

@ -0,0 +1,169 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)j0.3 6.7 (Berkeley) 4/19/91
.\" $FreeBSD: src/lib/msun/man/j0.3,v 1.15 2008/02/18 19:02:49 das Exp $
.\"
.Dd February 18, 2008
.Dt J0 3
.Os
.Sh NAME
.Nm j0 ,
.Nm j0f ,
.Nm j1 ,
.Nm j1f ,
.Nm jn ,
.Nm jnf ,
.Nm y0 ,
.Nm y0f ,
.Nm y1 ,
.Nm y1f ,
.Nm yn ,
.Nm ynf
.Nd Bessel functions of first and second kind
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn j0 "double x"
.Ft float
.Fn j0f "float x"
.Ft double
.Fn j1 "double x"
.Ft float
.Fn j1f "float x"
.Ft double
.Fn jn "int n" "double x"
.Ft float
.Fn jnf "int n" "float x"
.Ft double
.Fn y0 "double x"
.Ft float
.Fn y0f "float x"
.Ft double
.Fn y1 "double x"
.Ft float
.Fn y1f "float x"
.Ft double
.Fn yn "int n" "double x"
.Ft float
.Fn ynf "int n" "float x"
.Sh DESCRIPTION
The functions
.Fn j0 ,
.Fn j0f ,
.Fn j1
and
.Fn j1f
compute the
.Em Bessel function of the first kind of the order
0 and the
.Em order
1, respectively,
for the
real value
.Fa x ;
the functions
.Fn jn
and
.Fn jnf
compute the
.Em Bessel function of the first kind of the integer
.Em order
.Fa n
for the real value
.Fa x .
.Pp
The functions
.Fn y0 ,
.Fn y0f ,
.Fn y1 ,
and
.Fn y1f
compute the linearly independent
.Em Bessel function of the second kind of the order
0 and the
.Em order
1, respectively,
for the
positive
.Em real
value
.Fa x ;
the functions
.Fn yn
and
.Fn ynf
compute the
.Em Bessel function of the second kind for the integer
.Em order
.Fa n
for the positive
.Em real
value
.Fa x .
.Sh RETURN VALUES
These routines return values of their respective Bessel functions.
For large positive inputs, they may underflow and return \*(Pm0.
.Pp
The following applies to
.Fn y0 ,
.Fn y0f ,
.Fn y1 ,
.Fn y1f ,
.Fn yn ,
and
.Fn ynf .
If
.Fa x
is negative, these routines will generate an invalid exception and
return \*(Na.
If
.Fa x
is 0 or a sufficiently small positive number, these routines
will generate an overflow exception and return -\*(If.
.Sh SEE ALSO
.Xr math 3
.Sh STANDARDS
The
.Fn j0 ,
.Fn j1 ,
.Fn jn ,
.Fn y0 ,
.Fn y1 ,
and
.Fn yn
functions conform to
.St -p1003.1-2001 .
The
.Ft float
versions are extensions.
.Sh HISTORY
This set of functions
appeared in
.At v7 .

189
man/lgamma.3 Normal file
View file

@ -0,0 +1,189 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)lgamma.3 6.6 (Berkeley) 12/3/92
.\" $FreeBSD: src/lib/msun/man/lgamma.3,v 1.24 2008/02/18 17:27:11 das Exp $
.\"
.Dd January 14, 2005
.Dt LGAMMA 3
.Os
.Sh NAME
.Nm lgamma ,
.Nm lgamma_r ,
.Nm lgammaf ,
.Nm lgammaf_r ,
.Nm gamma ,
.Nm gamma_r ,
.Nm gammaf ,
.Nm gammaf_r ,
.Nm tgamma ,
.Nm tgammaf
.Nd log gamma functions, gamma function
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft extern int
.Fa signgam ;
.sp
.Ft double
.Fn lgamma "double x"
.Ft double
.Fn lgamma_r "double x" "int *signgamp"
.Ft float
.Fn lgammaf "float x"
.Ft float
.Fn lgammaf_r "float x" "int *signgamp"
.Ft double
.Fn gamma "double x"
.Ft double
.Fn gamma_r "double x" "int *signgamp"
.Ft float
.Fn gammaf "float x"
.Ft float
.Fn gammaf_r "float x" "int *signgamp"
.Ft double
.Fn tgamma "double x"
.Ft float
.Fn tgammaf "float x"
.Sh DESCRIPTION
.Fn lgamma x
and
.Fn lgammaf x
.if t \{\
return ln\||\(*G(x)| where
.Bd -unfilled -offset indent
\(*G(x) = \(is\d\s8\z0\s10\u\u\s8\(if\s10\d t\u\s8x\-1\s10\d e\u\s8\-t\s10\d dt for x > 0 and
\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1.
.Ed
.\}
.if n \
return ln\||\(*G(x)|.
The external integer
.Fa signgam
returns the sign of \(*G(x).
.Pp
.Fn lgamma_r x signgamp
and
.Fn lgammaf_r x signgamp
provide the same functionality as
.Fn lgamma x
and
.Fn lgammaf x
but the caller must provide an integer to store the sign of \(*G(x).
.Pp
The
.Fn tgamma x
and
.Fn tgammaf x
functions return \(*G(x), with no effect on
.Fa signgam .
.Pp
.Fn gamma ,
.Fn gammaf ,
.Fn gamma_r ,
and
.Fn gammaf_r
are deprecated aliases for
.Fn lgamma ,
.Fn lgammaf ,
.Fn lgamma_r ,
and
.Fn lgammaf_r ,
respectively.
.Sh IDIOSYNCRASIES
Do not use the expression
.Dq Li signgam\(**exp(lgamma(x))
to compute g := \(*G(x).
Instead use a program like this (in C):
.Bd -literal -offset indent
lg = lgamma(x); g = signgam\(**exp(lg);
.Ed
.Pp
Only after
.Fn lgamma
or
.Fn lgammaf
has returned can signgam be correct.
.Pp
For arguments in its range,
.Fn tgamma
is preferred, as for positive arguments
it is accurate to within one unit in the last place.
Exponentiation of
.Fn lgamma
will lose up to 10 significant bits.
.Sh RETURN VALUES
.Fn gamma ,
.Fn gamma_r ,
.Fn gammaf ,
.Fn gammaf_r ,
.Fn lgamma ,
.Fn lgamma_r ,
.Fn lgammaf ,
and
.Fn lgammaf_r
return appropriate values unless an argument is out of range.
Overflow will occur for sufficiently large positive values, and
non-positive integers.
For large non-integer negative values,
.Fn tgamma
will underflow.
.Sh SEE ALSO
.Xr math 3
.Sh STANDARDS
The
.Fn lgamma ,
.Fn lgammaf ,
.Fn tgamma ,
and
.Fn tgammaf
functions are expected to conform to
.St -isoC-99 .
.Sh HISTORY
The
.Fn lgamma
function appeared in
.Bx 4.3 .
The
.Fn gamma
function appeared in
.Bx 4.4
as a function which computed \(*G(x).
This version was used in
.Fx 1.1 .
The name
.Fn gamma
was originally dedicated to the
.Fn lgamma
function,
and that usage was restored by switching to Sun's fdlibm in
.Fx 1.1.5 .
The
.Fn tgamma
function appeared in
.Fx 5.0 .

118
man/log.3 Normal file
View file

@ -0,0 +1,118 @@
.\" Copyright (c) 2008-2010 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/log.3,v 1.2 2010/12/05 22:11:22 das Exp $
.\"
.Dd December 5, 2010
.Dt LOG 3
.Os
.Sh NAME
.Nm log ,
.Nm logf ,
.Nm logl ,
.Nm log10 ,
.Nm log10f ,
.Nm log2 ,
.Nm log2f ,
.Nm log1p ,
.Nm log1pf
.Nd logarithm functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn log "double x"
.Ft float
.Fn logf "float x"
.Ft double
.Fn log10 "double x"
.Ft float
.Fn log10f "float x"
.Ft double
.Fn log2 "double x"
.Ft float
.Fn log2f "float x"
.Ft double
.Fn log1p "double x"
.Ft float
.Fn log1pf "float x"
.Sh DESCRIPTION
The
.Fn log
and
.Fn logf
functions compute the natural logarithm of
.Fa x .
.Pp
The
.Fn log10
and
.Fn log10f
functions compute the logarithm base 10 of
.Fa x ,
while
.Fn log2
and
.Fn log2f
compute the logarithm base 2 of
.Fa x .
.Pp
The
.Fn log1p
and
.Fn log1pf
functions compute the natural logarithm of
.No "1 + x" .
Computing the natural logarithm as
.Li log1p(x)
is more accurate than computing it as
.Li log(1 + x)
when
.Fa x
is close to zero.
.Sh RETURN VALUES
These functions return the requested logarithm; the logarithm of 1 is +0.
An attempt to take the logarithm of \*(Pm0 results in a divide-by-zero
exception, and -\*(If is returned.
Otherwise, attempting to take the logarithm of a negative number
results in an invalid exception and a return value of \*(Na.
.Sh SEE ALSO
.Xr exp 3 ,
.Xr ilogb 3 ,
.Xr math 3 ,
.Xr pow 3
.Sh STANDARDS
The
.Fn log ,
.Fn logf ,
.Fn log10 ,
.Fn log10f ,
.Fn log2 ,
.Fn log2f ,
.Fn log1p ,
and
.Fn log1pf
functions conform to
.St -isoC-99 .

104
man/lrint.3 Normal file
View file

@ -0,0 +1,104 @@
.\" Copyright (c) 2005 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/lrint.3,v 1.3 2008/01/14 02:12:07 das Exp $
.\"
.Dd January 13, 2008
.Dt LRINT 3
.Os
.Sh NAME
.Nm llrint ,
.Nm llrintf ,
.Nm llrintl ,
.Nm lrint ,
.Nm lrintf ,
.Nm lrintl
.Nd "convert to integer"
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft "long long"
.Fn llrint "double x"
.Ft "long long"
.Fn llrintf "float x"
.Ft "long long"
.Fn llrintl "long double x"
.Ft long
.Fn lrint "double x"
.Ft long
.Fn lrintf "float x"
.Ft long
.Fn lrintl "long double x"
.Sh DESCRIPTION
The
.Fn lrint
function returns the integer nearest to its argument
.Fa x
according to the current rounding mode.
If the rounded result is too large to be represented as a
.Vt long
value, an invalid exception is raised and the return value is undefined.
Otherwise, if
.Fa x
is not an integer,
.Fn lrint
raises an inexact exception.
When the rounded result is representable as a
.Vt long ,
the expression
.Fn lrint x
is equivalent to
.Po Vt long Pc Ns Fn rint x
(although the former may be more efficient).
.Pp
The
.Fn llrint ,
.Fn llrintf ,
.Fn llrintl ,
.Fn lrintf ,
and
.Fn lrintl
functions differ from
.Fn lrint
only in their input and output types.
.Sh SEE ALSO
.Xr lround 3 ,
.Xr math 3 ,
.Xr rint 3 ,
.Xr round 3
.Sh STANDARDS
These functions conform to
.St -isoC-99 .
.Sh HISTORY
The
.Fn llrint ,
.Fn llrintf ,
.Fn lrint ,
and
.Fn lrintf
routines first appeared in
.Fx 5.4 .
The long double variants were introduced in
.Fx 8.0 .

112
man/lround.3 Normal file
View file

@ -0,0 +1,112 @@
.\" Copyright (c) 2005 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/lround.3,v 1.4 2005/06/15 19:04:04 ru Exp $
.\"
.Dd April 7, 2005
.Dt LROUND 3
.Os
.Sh NAME
.Nm llround ,
.Nm llroundf ,
.Nm llroundl ,
.Nm lround ,
.Nm lroundf ,
.Nm lroundl
.Nd "convert to nearest integral value"
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft "long long"
.Fn llround "double x"
.Ft "long long"
.Fn llroundf "float x"
.Ft "long long"
.Fn llroundl "long double x"
.Ft long
.Fn lround "double x"
.Ft long
.Fn lroundf "float x"
.Ft long
.Fn lroundl "long double x"
.Sh DESCRIPTION
The
.Fn lround
function returns the integer nearest to its argument
.Fa x ,
rounding away from zero in halfway cases.
If the rounded result is too large to be represented as a
.Vt long
value, an invalid exception is raised and the return value is undefined.
Otherwise, if
.Fa x
is not an integer,
.Fn lround
may raise an inexact exception.
When the rounded result is representable as a
.Vt long ,
the expression
.Fn lround x
is equivalent to
.Po Vt long Pc Ns Fn round x
(although the former may be more efficient).
.Pp
The
.Fn llround ,
.Fn llroundf ,
.Fn llroundl ,
.Fn lroundf
and
.Fn lroundl
functions differ from
.Fn lround
only in their input and output types.
.Sh SEE ALSO
.Xr lrint 3 ,
.Xr math 3 ,
.Xr rint 3 ,
.Xr round 3
.Sh STANDARDS
The
.Fn llround ,
.Fn llroundf ,
.Fn llroundl ,
.Fn lround ,
.Fn lroundf ,
and
.Fn lroundl
functions conform to
.St -isoC-99 .
.Sh HISTORY
The
.Vt float
and
.Vt double
versions of these routines first appeared in
.Fx 5.4 .
The
.Vt "long double"
versions appeared in
.Fx 6.0 .

254
man/math.3 Normal file
View file

@ -0,0 +1,254 @@
.\" Copyright (c) 1985 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)math.3 6.10 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/math.3,v 1.34 2011/10/17 06:10:32 das Exp $
.\"
.Dd December 5, 2010
.Dt MATH 3
.Os
.Sh NAME
.Nm math
.Nd "floating-point mathematical library"
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Sh DESCRIPTION
The math library includes the following components:
.Bl -column "<complex.h>" "polymorphic (type-generic) versions of functions" -compact -offset indent
.In math.h Ta basic routines and real-valued functions
.In complex.h Ta complex number support
.In tgmath.h Ta polymorphic (type-generic) versions of functions
.In fenv.h Ta routines to control rounding and exceptions
.El
The rest of this manual page describes the functions provided by
.In math.h .
Please consult
.Xr complex 3 ,
.Xr tgmath 3 ,
and
.Xr fenv 3
for information on the other components.
.Sh "LIST OF FUNCTIONS"
Each of the following
.Vt double
functions has a
.Vt float
counterpart with an
.Ql f
appended to the name and a
.Vt "long double"
counterpart with an
.Ql l
appended.
As an example, the
.Vt float
and
.Vt "long double"
counterparts of
.Ft double
.Fn acos "double x"
are
.Ft float
.Fn acosf "float x"
and
.Ft "long double"
.Fn acosl "long double x" ,
respectively.
The classification macros and silent order predicates are type generic and
should not be suffixed with
.Ql f
or
.Ql l .
.de Cl
.Bl -column "isgreaterequal" "bessel function of the second kind of the order 0"
.Em "Name Description"
..
.Ss Algebraic Functions
.Cl
cbrt cube root
fma fused multiply-add
hypot Euclidean distance
sqrt square root
.El
.Ss Classification Macros
.Cl
fpclassify classify a floating-point value
isfinite determine whether a value is finite
isinf determine whether a value is infinite
isnan determine whether a value is \*(Na
isnormal determine whether a value is normalized
.El
.Ss Exponent Manipulation Functions
.Cl
frexp extract exponent and mantissa
ilogb extract exponent
ldexp multiply by power of 2
logb extract exponent
scalbln adjust exponent
scalbn adjust exponent
.El
.Ss Extremum- and Sign-Related Functions
.Cl
copysign copy sign bit
fabs absolute value
fdim positive difference
fmax maximum function
fmin minimum function
signbit extract sign bit
.El
.Ss Not a Number Functions
.Cl
nan generate a quiet \*(Na
.El
.Ss Residue and Rounding Functions
.Cl
ceil integer no less than
floor integer no greater than
fmod positive remainder
llrint round to integer in fixed-point format
llround round to nearest integer in fixed-point format
lrint round to integer in fixed-point format
lround round to nearest integer in fixed-point format
modf extract integer and fractional parts
nearbyint round to integer (silent)
nextafter next representable value
nexttoward next representable value
remainder remainder
remquo remainder with partial quotient
rint round to integer
round round to nearest integer
trunc integer no greater in magnitude than
.El
.Pp
The
.Fn ceil ,
.Fn floor ,
.Fn llround ,
.Fn lround ,
.Fn round ,
and
.Fn trunc
functions round in predetermined directions, whereas
.Fn llrint ,
.Fn lrint ,
and
.Fn rint
round according to the current (dynamic) rounding mode.
For more information on controlling the dynamic rounding mode, see
.Xr fenv 3
and
.Xr fesetround 3 .
.Ss Silent Order Predicates
.Cl
isgreater greater than relation
isgreaterequal greater than or equal to relation
isless less than relation
islessequal less than or equal to relation
islessgreater less than or greater than relation
isunordered unordered relation
.El
.Ss Transcendental Functions
.Cl
acos inverse cosine
acosh inverse hyperbolic cosine
asin inverse sine
asinh inverse hyperbolic sine
atan inverse tangent
atanh inverse hyperbolic tangent
atan2 atan(y/x); complex argument
cos cosine
cosh hyperbolic cosine
erf error function
erfc complementary error function
exp exponential base e
exp2 exponential base 2
expm1 exp(x)\-1
j0 Bessel function of the first kind of the order 0
j1 Bessel function of the first kind of the order 1
jn Bessel function of the first kind of the order n
lgamma log gamma function
log natural logarithm
log10 logarithm to base 10
log1p log(1+x)
log2 base 2 logarithm
pow exponential x**y
sin trigonometric function
sinh hyperbolic function
tan trigonometric function
tanh hyperbolic function
tgamma gamma function
y0 Bessel function of the second kind of the order 0
y1 Bessel function of the second kind of the order 1
yn Bessel function of the second kind of the order n
.El
.Pp
The routines
in this section might not produce a result that is correctly rounded,
so reproducible results cannot be guaranteed across platforms.
For most of these functions, however, incorrect rounding occurs
rarely, and then only in very-close-to-halfway cases.
.Sh SEE ALSO
.Xr complex 3 ,
.Xr fenv 3 ,
.Xr ieee 3 ,
.Xr tgmath 3
.Sh HISTORY
A math library with many of the present functions appeared in
.At v7 .
The library was substantially rewritten for
.Bx 4.3
to provide
better accuracy and speed on machines supporting either VAX
or IEEE 754 floating-point.
Most of this library was replaced with FDLIBM, developed at Sun
Microsystems, in
.Fx 1.1.5 .
Additional routines, including ones for
.Vt float
and
.Vt long double
values, were written for or imported into subsequent versions of FreeBSD.
.Sh BUGS
Some of the
.Vt "long double"
math functions in
.St -isoC-99
are not available.
.Pp
Many of the routines to compute transcendental functions produce
inaccurate results in other than the default rounding mode.
.Pp
On the i386 platform, trigonometric argument reduction is not
performed accurately for huge arguments, resulting in
large errors
for such arguments to
.Fn cos ,
.Fn sin ,
and
.Fn tan .

99
man/nan.3 Normal file
View file

@ -0,0 +1,99 @@
.\" Copyright (c) 2007 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/nan.3,v 1.1 2007/12/16 21:19:28 das Exp $
.\"
.Dd December 16, 2007
.Dt NAN 3
.Os
.Sh NAME
.Nm nan ,
.Nm nanf ,
.Nm nanl
.Nd quiet \*(Nas
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn nan "const char *s"
.Ft float
.Fn nanf "const char *s"
.Ft long double
.Fn nanl "const char *s"
.Sh DESCRIPTION
The
.Dv NAN
macro expands to a quiet \*(Na (Not A Number).
Similarly, each of the
.Fn nan ,
.Fn nanf ,
and
.Fn nanl
functions generate a quiet \*(Na value without raising an invalid exception.
The argument
.Fa s
should point to either an empty string or a hexadecimal representation
of a non-negative integer (e.g., "0x1234".)
In the latter case, the integer is encoded in some free bits in the
representation of the \*(Na, which sometimes store
machine-specific information about why a particular \*(Na was generated.
There are 22 such bits available for
.Vt float
variables, 51 bits for
.Vt double
variables, and at least 51 bits for a
.Vt long double .
If
.Fa s
is improperly formatted or represents an integer that is too large,
then the particular encoding of the quiet \*(Na that is returned
is indeterminate.
.Sh COMPATIBILITY
Calling these functions with a non-empty string isn't portable.
Another operating system may translate the string into a different
\*(Na encoding, and furthermore, the meaning of a given \*(Na encoding
varies across machine architectures.
If you understood the innards of a particular platform well enough to
know what string to use, then you would have no need for these functions
anyway, so don't use them.
Use the
.Dv NAN
macro instead.
.Sh SEE ALSO
.Xr fenv 3 ,
.Xr ieee 3 ,
.Xr isnan 3 ,
.Xr math 3 ,
.Xr strtod 3
.Sh STANDARDS
The
.Fn nan ,
.Fn nanf ,
and
.Fn nanl
functions and the
.Dv NAN
macro conform to
.St -isoC-99 .

96
man/nextafter.3 Normal file
View file

@ -0,0 +1,96 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/nextafter.3,v 1.3 2007/01/09 01:02:06 imp Exp $
.\"
.Dd May 4, 2005
.Dt NEXTAFTER 3
.Os
.Sh NAME
.Nm nextafter ,
.Nm nextafterf ,
.Nm nextafterl ,
.Nm nexttoward ,
.Nm nexttowardf ,
.Nm nexttowardl
.Nd next representable value
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn nextafter "double x" "double y"
.Ft float
.Fn nextafterf "float x" "float y"
.Ft long double
.Fn nextafterl "long double x" "long double y"
.Ft double
.Fn nexttoward "double x" "long double y"
.Ft float
.Fn nexttowardf "float x" "long double y"
.Ft long double
.Fn nexttowardl "long double x" "long double y"
.Sh DESCRIPTION
These functions
return the next machine representable number from
.Fa x
in direction
.Fa y .
.Sh SEE ALSO
.Xr ieee 3 ,
.Xr math 3
.Sh STANDARDS
The
.Fn nextafter ,
.Fn nextafterf ,
.Fn nextafterl ,
.Fn nexttoward ,
.Fn nexttowardf ,
and
.Fn nexttowardl
routines conform to
.St -isoC-99 .
They implement the Nextafter function recommended by
.St -ieee754 ,
with the extension that
.Fn nextafter +0.0, -0.0
returns
.Li -0.0 ,
and
.Fn nextafter -0.0, +0.0
returns
.Li +0.0 .
.Sh HISTORY
The
.Fn nextafter
function appeared in
.Bx 4.3 ,
and
.Fn nextafterf
appeared in
.Fx 2.0 .

159
man/remainder.3 Normal file
View file

@ -0,0 +1,159 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/remainder.3,v 1.7 2010/06/02 10:20:38 uqs Exp $
.\"
.Dd March 30, 2008
.Dt REMAINDER 3
.Os
.Sh NAME
.Nm remainder ,
.Nm remainderf ,
.Nm remainderl ,
.Nm remquo ,
.Nm remquof ,
.Nm remquol
.Nd minimal residue functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn remainder "double x" "double y"
.Ft float
.Fn remainderf "float x" "float y"
.Ft long double
.Fn remainderl "long double x" "long double y"
.Ft double
.Fn remquo "double x" "double y" "int *quo"
.Ft float
.Fn remquof "float x" "float y" "int *quo"
.Ft long double
.Fn remquol "long double x" "long double y" "int *quo"
.Sh DESCRIPTION
.Fn remainder ,
.Fn remainderf ,
.Fn remainderl ,
.Fn remquo ,
.Fn remquof ,
and
.Fn remquol
return the remainder
.Fa r
:=
.Fa x
\-
.Fa n\(**y
where
.Fa n
is the integer nearest the exact value of
.Bk -words
.Fa x Ns / Ns Fa y ;
.Ek
moreover if
.Pf \*(Ba Fa n
\-
.Sm off
.Fa x No / Fa y No \*(Ba
.Sm on
=
1/2
then
.Fa n
is even.
Consequently
the remainder is computed exactly and
.Sm off
.Pf \*(Ba Fa r No \*(Ba
.Sm on
\*(Le
.Sm off
.Pf \*(Ba Fa y No \*(Ba/2 .
.Sm on
But attempting to take the remainder when
.Fa y
is 0 or
.Fa x
is \*(Pm\*(If is an invalid operation that produces a \*(Na.
.Pp
The
.Fn remquo ,
.Fn remquof ,
and
.Fn remquol
functions also store the last
.Va k
bits of
.Fa n
in the location pointed to by
.Fa quo ,
provided that
.Fa n
exists.
The number of bits
.Va k
is platform-specific, but is guaranteed to be at least 3.
.Sh SEE ALSO
.Xr fmod 3 ,
.Xr ieee 3 ,
.Xr math 3
.Sh STANDARDS
The
.Fn remainder ,
.Fn remainderf ,
.Fn remainderl ,
.Fn remquo ,
.Fn remquof ,
and
.Fn remquol
routines conform to
.St -isoC-99 .
The remainder is as defined in
.St -ieee754 .
.Sh HISTORY
The
.Fn remainder
and
.Fn remainderf
functions appeared in
.Bx 4.3
and
.Fx 2.0 ,
respectively.
The
.Fn remquo
and
.Fn remquof
functions were added in
.Fx 6.0 ,
and
.Fn remainderl
and
.Fn remquol
were added in
.Fx 8.0 .

103
man/rint.3 Normal file
View file

@ -0,0 +1,103 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)rint.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/rint.3,v 1.13 2008/01/14 02:12:07 das Exp $
.\"
.Dd January 13, 2008
.Dt RINT 3
.Os
.Sh NAME
.Nm nearbyint ,
.Nm nearbyintf ,
.Nm nearbyintl ,
.Nm rint ,
.Nm rintf ,
.Nm rintl
.Nd round to integral value in floating-point format
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn nearbyint "double x"
.Ft float
.Fn nearbyintf "float x"
.Ft long double
.Fn nearbyintl "long double x"
.Ft double
.Fn rint "double x"
.Ft float
.Fn rintf "float x"
.Ft long double
.Fn rintl "long double x"
.Sh DESCRIPTION
The
.Fn rint ,
.Fn rintf ,
and
.Fn rintl
functions return the integral value nearest to
.Fa x
according to the prevailing rounding mode.
These functions raise an inexact exception when the original argument
is not an exact integer.
.Pp
The
.Fn nearbyint ,
.Fn nearbyintf ,
and
.Fn nearbyintl
functions perform the same operation, except that they do not raise
an inexact exception.
.Sh SEE ALSO
.Xr abs 3 ,
.Xr ceil 3 ,
.Xr fabs 3 ,
.Xr fenv 3 ,
.Xr floor 3 ,
.Xr ieee 3 ,
.Xr lrint 3 ,
.Xr lround 3 ,
.Xr math 3 ,
.Xr round 3
.Sh STANDARDS
These functions conform to
.St -isoC-99 .
.Sh HISTORY
A
.Fn rint
function appeared in
.At v6 .
The
.Fn nearbyint
and
.Fn nearbyintf
functions appeared in
.Fx 5.3 ,
and the long double variants were first available in
.Fx 8.0 .

80
man/round.3 Normal file
View file

@ -0,0 +1,80 @@
.\" Copyright (c) 2003, Steven G. Kargl
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/round.3,v 1.6 2005/06/15 19:04:04 ru Exp $
.\"
.Dd April 7, 2005
.Dt ROUND 3
.Os
.Sh NAME
.Nm round ,
.Nm roundf ,
.Nm roundl
.Nd round to nearest integral value
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn round "double x"
.Ft float
.Fn roundf "float x"
.Ft "long double"
.Fn roundl "long double x"
.Sh DESCRIPTION
The
.Fn round ,
.Fn roundf ,
and
.Fn roundl
functions return the nearest integral value to
.Fa x ;
if
.Fa x
lies halfway between two integral values, then these
functions return the integral value with the larger
absolute value (i.e., they round away from zero).
.Sh SEE ALSO
.Xr ceil 3 ,
.Xr floor 3 ,
.Xr ieee 3 ,
.Xr lrint 3 ,
.Xr lround 3 ,
.Xr math 3 ,
.Xr rint 3 ,
.Xr trunc 3
.Sh STANDARDS
These functions conform to
.St -isoC-99 .
.Sh HISTORY
The
.Fn round
and
.Fn roundf
functions appeared in
.Fx 5.3 .
The
.Fn roundl
function appeared in
.Fx 6.0 .

91
man/scalbn.3 Normal file
View file

@ -0,0 +1,91 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/scalbn.3,v 1.4 2007/01/09 01:02:06 imp Exp $
.\"
.Dd March 4, 2005
.Dt SCALBN 3
.Os
.Sh NAME
.Nm scalbln ,
.Nm scalblnf ,
.Nm scalblnl ,
.Nm scalbn ,
.Nm scalbnf ,
.Nm scalbnl
.Nd adjust exponent
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn scalbln "double x" "long n"
.Ft float
.Fn scalblnf "float x" "long n"
.Ft long double
.Fn scalblnl "long double x" "long n"
.Ft double
.Fn scalbn "double x" "int n"
.Ft float
.Fn scalbnf "float x" "int n"
.Ft long double
.Fn scalbnl "long double x" "int n"
.Sh DESCRIPTION
These routines return
.Fa x Ns \(**(2** Ns Fa n )
computed by exponent manipulation.
.Sh SEE ALSO
.Xr ieee 3 ,
.Xr math 3
.Sh STANDARDS
These routines conform to
.St -isoC-99 ,
and they implement the Scalb function recommended by
.St -ieee754 .
.Sh HISTORY
The
.Fn scalbn
and
.Fn scalbnf
functions appeared in
.Bx 4.3
and
.Fx 2.0 ,
respectively.
The
.Fn scalbln
and
.Fn scalblnf
functions first appeared in
.Fx 5.3 ,
and
.Fn scalblnl
and
.Fn scalbln
in
.Fx 6.0 .

57
man/signbit.3 Normal file
View file

@ -0,0 +1,57 @@
.\" Copyright (c) 2003 Mike Barcroft <mike@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/signbit.3,v 1.1 2004/07/19 08:16:10 das Exp $
.\"
.Dd July 18, 2004
.Dt SIGNBIT 3
.Os
.Sh NAME
.Nm signbit
.Nd "determine whether a floating-point number's sign is negative"
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft int
.Fn signbit "real-floating x"
.Sh DESCRIPTION
The
.Fn signbit
macro takes an argument of
.Fa x
and returns non-zero if the value of its sign is negative, otherwise 0.
.Sh SEE ALSO
.Xr fpclassify 3 ,
.Xr math 3
.Sh STANDARDS
The
.Fn signbit
macro conforms to
.St -isoC-99 .
.Sh HISTORY
The
.Fn signbit
macro was added in
.Fx 5.1 .

82
man/sin.3 Normal file
View file

@ -0,0 +1,82 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" @(#)sin.3 6.7 (Berkeley) 4/19/91
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)sin.3 6.7 (Berkeley) 4/19/91
.\" $FreeBSD: src/lib/msun/man/sin.3,v 1.12 2011/10/17 05:41:03 das Exp $
.\"
.Dd January 24, 2008
.Dt SIN 3
.Os
.Sh NAME
.Nm sin ,
.Nm sinf ,
.Nm sinl
.Nd sine functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn sin "double x"
.Ft float
.Fn sinf "float x"
.Ft long double
.Fn sinl "long double x"
.Sh DESCRIPTION
The
.Fn sin ,
.Fn sinf ,
and
.Fn sinl
functions compute the sine of
.Fa x
(measured in radians).
A large magnitude argument may yield a result with little
or no significance.
.Sh RETURN VALUES
The
.Fn sin ,
.Fn sinf ,
and
.Fn sinl
functions return the sine value.
.Sh SEE ALSO
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
.Xr csin 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr math 3 ,
.Xr sinh 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Sh STANDARDS
These functions conform to
.St -isoC-99 .

68
man/sinh.3 Normal file
View file

@ -0,0 +1,68 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)sinh.3 6.6 (Berkeley) 4/19/91
.\" $FreeBSD: src/lib/msun/man/sinh.3,v 1.14 2011/10/17 05:41:03 das Exp $
.Dd January 14, 2005
.Dt SINH 3
.Os
.Sh NAME
.Nm sinh ,
.Nm sinhf
.Nd hyperbolic sine function
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn sinh "double x"
.Ft float
.Fn sinhf "float x"
.Sh DESCRIPTION
The
.Fn sinh
and the
.Fn sinhf
functions compute the hyperbolic sine of
.Fa x .
.Sh SEE ALSO
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr csinh 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Sh STANDARDS
The
.Fn sinh
function conforms to
.St -isoC .

122
man/sqrt.3 Normal file
View file

@ -0,0 +1,122 @@
.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)sqrt.3 6.4 (Berkeley) 5/6/91
.\" $FreeBSD: src/lib/msun/man/sqrt.3,v 1.16 2011/03/12 16:50:39 kargl Exp $
.\"
.Dd March 5, 2011
.Dt SQRT 3
.Os
.Sh NAME
.Nm cbrt ,
.Nm cbrtf ,
.Nm cbrtl ,
.Nm sqrt ,
.Nm sqrtf ,
.Nm sqrtl
.Nd cube root and square root functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn cbrt "double x"
.Ft float
.Fn cbrtf "float x"
.Ft long double
.Fn cbrtl "long double x"
.Ft double
.Fn sqrt "double x"
.Ft float
.Fn sqrtf "float x"
.Ft long double
.Fn sqrtl "long double x"
.Sh DESCRIPTION
The
.Fn cbrt ,
.Fn cbrtf ,
and
.Fn cbrtl
functions compute
the cube root of
.Ar x .
.Pp
The
.Fn sqrt ,
.Fn sqrtf ,
and
.Fn sqrtl
functions compute the
non-negative square root of
.Ar x .
.Sh RETURN VALUES
The
.Fn cbrt ,
.Fn cbrtf ,
and
.Fn cbrtl
functions return the requested cube root.
The
.Fn sqrt ,
.Fn sqrtf ,
and
.Fn sqrtl
functions return the requested square root
unless an error occurs.
An attempt to take the
.Fn sqrt
of negative
.Fa x
raises an invalid exception and causes an \*(Na to be returned
(except that the square root of -0 is valid and equal to -0.)
.Sh SEE ALSO
.Xr fenv 3 ,
.Xr math 3
.Sh STANDARDS
The
.Fn cbrt ,
.Fn cbrtf ,
.Fn cbrtl ,
.Fn sqrt ,
.Fn sqrtf ,
and
.Fn sqrtl
functions conform to
.St -isoC-99 .
.Sh HISTORY
The
.Fn cbrt
function appeared in
.Bx 4.3 .
The
.Fn sqrtl
function appeared in
.Fx 8.0 .
The
.Fn cbrtl
function appeared in
.Fx 9.0 .

83
man/tan.3 Normal file
View file

@ -0,0 +1,83 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)tan.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/tan.3,v 1.12 2011/10/17 05:41:03 das Exp $
.\"
.Dd January 24, 2008
.Dt TAN 3
.Os
.Sh NAME
.Nm tan ,
.Nm tanf ,
.Nm tanl
.Nd tangent functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn tan "double x"
.Ft float
.Fn tanf "float x"
.Ft long double
.Fn tanl "long double x"
.Sh DESCRIPTION
The
.Fn tan ,
.Fn tanf ,
and
.Fn tanl
functions compute the tangent of
.Fa x
(measured in radians).
A large magnitude argument may yield a result
with little or no significance.
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
The
.Fn tan ,
.Fn tanf ,
and
.Fn tanl
functions return the tangent value.
.Sh SEE ALSO
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr ctan 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tanh 3
.Sh STANDARDS
These functions conform to
.St -isoC-99 .

77
man/tanh.3 Normal file
View file

@ -0,0 +1,77 @@
.\" Copyright (c) 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)tanh.3 5.1 (Berkeley) 5/2/91
.\" $FreeBSD: src/lib/msun/man/tanh.3,v 1.12 2011/10/17 05:41:03 das Exp $
.\"
.Dd May 2, 1991
.Dt TANH 3
.Os
.Sh NAME
.Nm tanh ,
.Nm tanhf
.Nd hyperbolic tangent functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn tanh "double x"
.Ft float
.Fn tanhf "float x"
.Sh DESCRIPTION
The
.Fn tanh
and the
.Fn tanhf
functions compute the hyperbolic tangent of
.Fa x .
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
The
.Fn tanh
and the
.Fn tanhf
functions return the hyperbolic tangent value.
.Sh SEE ALSO
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr ctanh 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tan 3
.Sh STANDARDS
The
.Fn tanh
function conforms to
.St -isoC .

80
man/trunc.3 Normal file
View file

@ -0,0 +1,80 @@
.\" Copyright (c) 2004, 2005 David Schultz <das@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: src/lib/msun/man/trunc.3,v 1.3 2005/06/15 19:04:04 ru Exp $
.\"
.Dd April 16, 2005
.Dt TRUNC 3
.Os
.Sh NAME
.Nm trunc ,
.Nm truncf ,
.Nm truncl
.Nd nearest integral value with magnitude less than or equal to |x|
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn trunc "double x"
.Ft float
.Fn truncf "float x"
.Ft "long double"
.Fn truncl "long double x"
.Sh DESCRIPTION
The
.Fn trunc ,
.Fn truncf ,
and
.Fn truncl
functions return the nearest integral value with magnitude less than
or equal to
.Pf | Fa x Ns | .
They are equivalent to
.Fn rint ,
.Fn rintf ,
and
.Fn rintl ,
respectively, in the
.Dv FE_TOWARDZERO
rounding mode.
.Sh SEE ALSO
.Xr ceil 3 ,
.Xr fesetround 3 ,
.Xr floor 3 ,
.Xr math 3 ,
.Xr nextafter 3 ,
.Xr rint 3 ,
.Xr round 3
.Sh STANDARDS
The
.Fn trunc ,
.Fn truncf ,
and
.Fn truncl
functions conform to
.St -isoC-99 .
.Sh HISTORY
These routines first appeared in
.Fx 5.3 .

4
mips/Makefile.inc Normal file
View file

@ -0,0 +1,4 @@
# $FreeBSD: src/lib/msun/mips/Makefile.inc,v 1.1 2008/04/26 12:20:29 imp Exp $
LDBL_PREC = 53
SYM_MAPS += ${.CURDIR}/mips/Symbol.map

13
mips/Symbol.map Normal file
View file

@ -0,0 +1,13 @@
/*
* $FreeBSD: src/lib/msun/mips/Symbol.map,v 1.3 2011/10/10 15:43:09 das Exp $
*/
FBSD_1.0 {
};
FBSD_1.3 {
fesetexceptflag;
feraiseexcept;
fegetenv;
feholdexcept;
feupdateenv;
};

52
mips/fenv.c Normal file
View file

@ -0,0 +1,52 @@
/*-
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/mips/fenv.c,v 1.3 2011/10/16 05:37:56 das Exp $
*/
#define __fenv_static
#include "fenv.h"
#ifdef __GNUC_GNU_INLINE__
#error "This file must be compiled with C99 'inline' semantics"
#endif
/*
* Hopefully the system ID byte is immutable, so it's valid to use
* this as a default environment.
*/
const fenv_t __fe_dfl_env = 0;
extern inline int feclearexcept(int __excepts);
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
extern inline int feraiseexcept(int __excepts);
extern inline int fetestexcept(int __excepts);
extern inline int fegetround(void);
extern inline int fesetround(int __round);
extern inline int fegetenv(fenv_t *__envp);
extern inline int feholdexcept(fenv_t *__envp);
extern inline int fesetenv(const fenv_t *__envp);
extern inline int feupdateenv(const fenv_t *__envp);

223
mips/fenv.h Normal file
View file

@ -0,0 +1,223 @@
/*-
* Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/mips/fenv.h,v 1.2 2011/10/10 15:43:09 das Exp $
*/
#ifndef _FENV_H_
#define _FENV_H_
#include <sys/_types.h>
#ifndef __fenv_static
#define __fenv_static static
#endif
typedef __uint32_t fenv_t;
typedef __uint32_t fexcept_t;
/* Exception flags */
#define FE_INVALID 0x0001
#define FE_DIVBYZERO 0x0002
#define FE_OVERFLOW 0x0004
#define FE_UNDERFLOW 0x0008
#define FE_INEXACT 0x0010
#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
/* Rounding modes */
#define FE_TONEAREST 0x0000
#define FE_TOWARDZERO 0x0001
#define FE_UPWARD 0x0002
#define FE_DOWNWARD 0x0003
#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
FE_UPWARD | FE_TOWARDZERO)
__BEGIN_DECLS
/* Default floating-point environment */
extern const fenv_t __fe_dfl_env;
#define FE_DFL_ENV (&__fe_dfl_env)
/* We need to be able to map status flag positions to mask flag positions */
#define _FPUSW_SHIFT 16
#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)
#ifdef ARM_HARD_FLOAT
#define __rfs(__fpsr) __asm __volatile("rfs %0" : "=r" (*(__fpsr)))
#define __wfs(__fpsr) __asm __volatile("wfs %0" : : "r" (__fpsr))
#else
#define __rfs(__fpsr)
#define __wfs(__fpsr)
#endif
__fenv_static inline int
feclearexcept(int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
__fpsr &= ~__excepts;
__wfs(__fpsr);
return (0);
}
__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
*__flagp = __fpsr & __excepts;
return (0);
}
__fenv_static inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
__fpsr &= ~__excepts;
__fpsr |= *__flagp & __excepts;
__wfs(__fpsr);
return (0);
}
__fenv_static inline int
feraiseexcept(int __excepts)
{
fexcept_t __ex = __excepts;
fesetexceptflag(&__ex, __excepts); /* XXX */
return (0);
}
__fenv_static inline int
fetestexcept(int __excepts)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
return (__fpsr & __excepts);
}
__fenv_static inline int
fegetround(void)
{
/*
* Apparently, the rounding mode is specified as part of the
* instruction format on ARM, so the dynamic rounding mode is
* indeterminate. Some FPUs may differ.
*/
return (-1);
}
__fenv_static inline int
fesetround(int __round)
{
return (-1);
}
__fenv_static inline int
fegetenv(fenv_t *__envp)
{
__rfs(__envp);
return (0);
}
__fenv_static inline int
feholdexcept(fenv_t *__envp)
{
fenv_t __env;
__rfs(&__env);
*__envp = __env;
__env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
__wfs(__env);
return (0);
}
__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
__wfs(*__envp);
return (0);
}
__fenv_static inline int
feupdateenv(const fenv_t *__envp)
{
fexcept_t __fpsr;
__rfs(&__fpsr);
__wfs(*__envp);
feraiseexcept(__fpsr & FE_ALL_EXCEPT);
return (0);
}
#if __BSD_VISIBLE
/* We currently provide no external definitions of the functions below. */
static inline int
feenableexcept(int __mask)
{
fenv_t __old_fpsr, __new_fpsr;
__rfs(&__old_fpsr);
__new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT;
__wfs(__new_fpsr);
return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
static inline int
fedisableexcept(int __mask)
{
fenv_t __old_fpsr, __new_fpsr;
__rfs(&__old_fpsr);
__new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
__wfs(__new_fpsr);
return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
}
static inline int
fegetexcept(void)
{
fenv_t __fpsr;
__rfs(&__fpsr);
return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
}
#endif /* __BSD_VISIBLE */
__END_DECLS
#endif /* !_FENV_H_ */

4
powerpc/Makefile.inc Normal file
View file

@ -0,0 +1,4 @@
# $FreeBSD: src/lib/msun/powerpc/Makefile.inc,v 1.2 2006/03/27 23:59:45 deischen Exp $
LDBL_PREC = 53
SYM_MAPS += ${.CURDIR}/powerpc/Symbol.map

13
powerpc/Symbol.map Normal file
View file

@ -0,0 +1,13 @@
/*
* $FreeBSD: src/lib/msun/powerpc/Symbol.map,v 1.3 2011/10/10 15:43:09 das Exp $
*/
FBSD_1.0 {
};
FBSD_1.3 {
fesetexceptflag;
feraiseexcept;
fegetenv;
feholdexcept;
feupdateenv;
};

48
powerpc/fenv.c Normal file
View file

@ -0,0 +1,48 @@
/*-
* Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/powerpc/fenv.c,v 1.3 2011/10/16 05:37:56 das Exp $
*/
#define __fenv_static
#include "fenv.h"
#ifdef __GNUC_GNU_INLINE__
#error "This file must be compiled with C99 'inline' semantics"
#endif
const fenv_t __fe_dfl_env = 0x00000000;
extern inline int feclearexcept(int __excepts);
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);
extern inline int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
extern inline int feraiseexcept(int __excepts);
extern inline int fetestexcept(int __excepts);
extern inline int fegetround(void);
extern inline int fesetround(int __round);
extern inline int fegetenv(fenv_t *__envp);
extern inline int feholdexcept(fenv_t *__envp);
extern inline int fesetenv(const fenv_t *__envp);
extern inline int feupdateenv(const fenv_t *__envp);

274
powerpc/fenv.h Normal file
View file

@ -0,0 +1,274 @@
/*-
* Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/msun/powerpc/fenv.h,v 1.5 2011/10/10 15:43:09 das Exp $
*/
#ifndef _FENV_H_
#define _FENV_H_
#include <sys/_types.h>
#ifndef __fenv_static
#define __fenv_static static
#endif
typedef __uint32_t fenv_t;
typedef __uint32_t fexcept_t;
/* Exception flags */
#define FE_INEXACT 0x02000000
#define FE_DIVBYZERO 0x04000000
#define FE_UNDERFLOW 0x08000000
#define FE_OVERFLOW 0x10000000
#define FE_INVALID 0x20000000 /* all types of invalid FP ops */
/*
* The PowerPC architecture has extra invalid flags that indicate the
* specific type of invalid operation occurred. These flags may be
* tested, set, and cleared---but not masked---separately. All of
* these bits are cleared when FE_INVALID is cleared, but only
* FE_VXSOFT is set when FE_INVALID is explicitly set in software.
*/
#define FE_VXCVI 0x00000100 /* invalid integer convert */
#define FE_VXSQRT 0x00000200 /* square root of a negative */
#define FE_VXSOFT 0x00000400 /* software-requested exception */
#define FE_VXVC 0x00080000 /* ordered comparison involving NaN */
#define FE_VXIMZ 0x00100000 /* inf * 0 */
#define FE_VXZDZ 0x00200000 /* 0 / 0 */
#define FE_VXIDI 0x00400000 /* inf / inf */
#define FE_VXISI 0x00800000 /* inf - inf */
#define FE_VXSNAN 0x01000000 /* operation on a signalling NaN */
#define FE_ALL_INVALID (FE_VXCVI | FE_VXSQRT | FE_VXSOFT | FE_VXVC | \
FE_VXIMZ | FE_VXZDZ | FE_VXIDI | FE_VXISI | \
FE_VXSNAN | FE_INVALID)
#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
FE_ALL_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
/* Rounding modes */
#define FE_TONEAREST 0x0000
#define FE_TOWARDZERO 0x0001
#define FE_UPWARD 0x0002
#define FE_DOWNWARD 0x0003
#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
FE_UPWARD | FE_TOWARDZERO)
__BEGIN_DECLS
/* Default floating-point environment */
extern const fenv_t __fe_dfl_env;
#define FE_DFL_ENV (&__fe_dfl_env)
/* We need to be able to map status flag positions to mask flag positions */
#define _FPUSW_SHIFT 22
#define _ENABLE_MASK ((FE_DIVBYZERO | FE_INEXACT | FE_INVALID | \
FE_OVERFLOW | FE_UNDERFLOW) >> _FPUSW_SHIFT)
#ifndef _SOFT_FLOAT
#define __mffs(__env) __asm __volatile("mffs %0" : "=f" (*(__env)))
#define __mtfsf(__env) __asm __volatile("mtfsf 255,%0" : : "f" (__env))
#else
#define __mffs(__env)
#define __mtfsf(__env)
#endif
union __fpscr {
double __d;
struct {
__uint32_t __junk;
fenv_t __reg;
} __bits;
};
__fenv_static inline int
feclearexcept(int __excepts)
{
union __fpscr __r;
if (__excepts & FE_INVALID)
__excepts |= FE_ALL_INVALID;
__mffs(&__r.__d);
__r.__bits.__reg &= ~__excepts;
__mtfsf(__r.__d);
return (0);
}
__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
union __fpscr __r;
__mffs(&__r.__d);
*__flagp = __r.__bits.__reg & __excepts;
return (0);
}
__fenv_static inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
union __fpscr __r;
if (__excepts & FE_INVALID)
__excepts |= FE_ALL_EXCEPT;
__mffs(&__r.__d);
__r.__bits.__reg &= ~__excepts;
__r.__bits.__reg |= *__flagp & __excepts;
__mtfsf(__r.__d);
return (0);
}
__fenv_static inline int
feraiseexcept(int __excepts)
{
union __fpscr __r;
if (__excepts & FE_INVALID)
__excepts |= FE_VXSOFT;
__mffs(&__r.__d);
__r.__bits.__reg |= __excepts;
__mtfsf(__r.__d);
return (0);
}
__fenv_static inline int
fetestexcept(int __excepts)
{
union __fpscr __r;
__mffs(&__r.__d);
return (__r.__bits.__reg & __excepts);
}
__fenv_static inline int
fegetround(void)
{
union __fpscr __r;
__mffs(&__r.__d);
return (__r.__bits.__reg & _ROUND_MASK);
}
__fenv_static inline int
fesetround(int __round)
{
union __fpscr __r;
if (__round & ~_ROUND_MASK)
return (-1);
__mffs(&__r.__d);
__r.__bits.__reg &= ~_ROUND_MASK;
__r.__bits.__reg |= __round;
__mtfsf(__r.__d);
return (0);
}
__fenv_static inline int
fegetenv(fenv_t *__envp)
{
union __fpscr __r;
__mffs(&__r.__d);
*__envp = __r.__bits.__reg;
return (0);
}
__fenv_static inline int
feholdexcept(fenv_t *__envp)
{
union __fpscr __r;
__mffs(&__r.__d);
*__envp = __r.__d;
__r.__bits.__reg &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
__mtfsf(__r.__d);
return (0);
}
__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
union __fpscr __r;
__r.__bits.__reg = *__envp;
__mtfsf(__r.__d);
return (0);
}
__fenv_static inline int
feupdateenv(const fenv_t *__envp)
{
union __fpscr __r;
__mffs(&__r.__d);
__r.__bits.__reg &= FE_ALL_EXCEPT;
__r.__bits.__reg |= *__envp;
__mtfsf(__r.__d);
return (0);
}
#if __BSD_VISIBLE
/* We currently provide no external definitions of the functions below. */
static inline int
feenableexcept(int __mask)
{
union __fpscr __r;
fenv_t __oldmask;
__mffs(&__r.__d);
__oldmask = __r.__bits.__reg;
__r.__bits.__reg |= (__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT;
__mtfsf(__r.__d);
return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
}
static inline int
fedisableexcept(int __mask)
{
union __fpscr __r;
fenv_t __oldmask;
__mffs(&__r.__d);
__oldmask = __r.__bits.__reg;
__r.__bits.__reg &= ~((__mask & FE_ALL_EXCEPT) >> _FPUSW_SHIFT);
__mtfsf(__r.__d);
return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
}
static inline int
fegetexcept(void)
{
union __fpscr __r;
__mffs(&__r.__d);
return ((__r.__bits.__reg & _ENABLE_MASK) << _FPUSW_SHIFT);
}
#endif /* __BSD_VISIBLE */
__END_DECLS
#endif /* !_FENV_H_ */

5
sparc64/Makefile.inc Normal file
View file

@ -0,0 +1,5 @@
# $FreeBSD: src/lib/msun/sparc64/Makefile.inc,v 1.3 2006/03/27 23:59:45 deischen Exp $
ARCH_SRCS= e_sqrt.S e_sqrtf.S
LDBL_PREC= 113
SYM_MAPS+= ${.CURDIR}/sparc64/Symbol.map

Some files were not shown because too many files have changed in this diff Show more