am ff26e25b: am 44badc70: Merge "Upgrade libm."

# Via Android Git Automerger (1) and others
* commit 'ff26e25b51eb672a4c8244946e0f2b4328786f55':
  Upgrade libm.
This commit is contained in:
Elliott Hughes 2013-02-04 11:29:22 -08:00 committed by Android Git Automerger
commit fb7a4850b8
289 changed files with 8345 additions and 7943 deletions

View File

@ -87,6 +87,8 @@ typedef unsigned long __psize_t;
/* Standard system types */
typedef int __clock_t;
typedef int __clockid_t;
typedef double __double_t;
typedef float __float_t;
typedef long __ptrdiff_t;
typedef int __time_t;
typedef int __timer_t;

View File

@ -87,6 +87,8 @@ typedef unsigned long __psize_t;
/* Standard system types */
typedef int __clock_t;
typedef int __clockid_t;
typedef double __double_t;
typedef float __float_t;
typedef long __ptrdiff_t;
typedef int __time_t;
typedef int __timer_t;

View File

@ -177,6 +177,8 @@
#define __unused /* delete */
#endif
#define __pure2 __attribute__((__const__)) /* Android-added: used by FreeBSD libm */
#if __GNUC_PREREQ__(3, 1)
#define __used __attribute__((__used__))
#else
@ -313,6 +315,12 @@
#define __purefunc
#endif
#if __GNUC_PREREQ__(3, 1)
#define __always_inline __attribute__((__always_inline__))
#else
#define __always_inline
#endif
/*
* Macros for manipulating "link sets". Link sets are arrays of pointers
* to objects, which are gathered up by the linker.
@ -510,4 +518,11 @@
#define __BIONIC_FORTIFY_UNKNOWN_SIZE ((size_t) -1)
#endif
/* Android-added: for FreeBSD's libm. */
#define __weak_reference(sym,alias) \
__asm__(".weak " #alias); \
__asm__(".equ " #alias ", " #sym)
#define __strong_reference(sym,aliassym) \
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
#endif /* !_SYS_CDEFS_H_ */

64
libc/tools/check-symbols.py Executable file
View File

@ -0,0 +1,64 @@
#!/usr/bin/python
import glob
import os
import re
import string
import subprocess
import sys
toolchain = os.environ['ANDROID_TOOLCHAIN']
arch = re.sub(r'.*/linux-x86/([^/]+)/.*', r'\1', toolchain)
sys.stderr.write('Checking symbols for arch "%s"...\n' % arch)
def GetSymbols(library, functions_or_variables):
api = '9'
if library == 'libm' and arch == 'arm':
api = '3'
path = '%s/development/ndk/platforms/android-%s/arch-%s/symbols/%s.so.%s.txt' % (os.environ['ANDROID_BUILD_TOP'], api, arch, library, functions_or_variables)
symbols = set()
for line in open(path, 'r'):
symbols.add(line.rstrip())
#sys.stdout.write('%d %s in %s for %s\n' % (len(symbols), functions_or_variables, library, arch))
return symbols
def CheckSymbols(library, functions_or_variables):
expected_symbols = GetSymbols(library, functions_or_variables)
so_file = '%s/system/lib/%s.so' % (os.environ['ANDROID_PRODUCT_OUT'], library)
# Example readelf output:
# 264: 0001623c 4 FUNC GLOBAL DEFAULT 8 cabsf
# 266: 00016244 4 FUNC GLOBAL DEFAULT 8 dremf
# 267: 00019018 4 OBJECT GLOBAL DEFAULT 11 __fe_dfl_env
# 268: 00000000 0 FUNC GLOBAL DEFAULT UND __aeabi_dcmplt
r = re.compile(r' +\d+: [0-9a-f]+ +\d+ (FUNC|OBJECT) +\S+ +\S+ +\d+ (\S+)')
actual_symbols = set()
for line in subprocess.check_output(['readelf', '--dyn-syms', so_file]).split('\n'):
m = r.match(line)
if m:
if m.group(1) == 'FUNC' and functions_or_variables == 'functions':
actual_symbols.add(m.group(2))
elif m.group(1) == 'OBJECT' and functions_or_variables == 'variables':
actual_symbols.add(m.group(2))
#else:
#print 'ignoring: ' % line
missing = expected_symbols - actual_symbols
if len(missing) > 0:
sys.stderr.write('%d missing %s in %s for %s:\n' % (len(missing), functions_or_variables, library, arch))
for miss in sorted(missing):
sys.stderr.write(' %s\n' % miss)
return len(missing) == 0
CheckSymbols("libc", "functions")
CheckSymbols("libc", "variables")
CheckSymbols("libm", "functions")
CheckSymbols("libm", "variables")
sys.exit(0)

View File

@ -1,229 +1,254 @@
LOCAL_PATH:= $(call my-dir)
libm_common_src_files:= \
isinf.c \
fpclassify.c \
sincos.c \
bsdsrc/b_exp.c \
bsdsrc/b_log.c \
bsdsrc/b_tgamma.c \
src/e_acos.c \
src/e_acosf.c \
src/e_acosh.c \
src/e_acoshf.c \
src/e_asin.c \
src/e_asinf.c \
src/e_atan2.c \
src/e_atan2f.c \
src/e_atanh.c \
src/e_atanhf.c \
src/e_cosh.c \
src/e_coshf.c \
src/e_exp.c \
src/e_expf.c \
src/e_fmod.c \
src/e_fmodf.c \
src/e_gamma.c \
src/e_gamma_r.c \
src/e_gammaf.c \
src/e_gammaf_r.c \
src/e_hypot.c \
src/e_hypotf.c \
src/e_j0.c \
src/e_j0f.c \
src/e_j1.c \
src/e_j1f.c \
src/e_jn.c \
src/e_jnf.c \
src/e_lgamma.c \
src/e_lgamma_r.c \
src/e_lgammaf.c \
src/e_lgammaf_r.c \
src/e_log.c \
src/e_log10.c \
src/e_log10f.c \
src/e_logf.c \
src/e_pow.c \
src/e_powf.c \
src/e_rem_pio2.c \
src/e_rem_pio2f.c \
src/e_remainder.c \
src/e_remainderf.c \
src/e_scalb.c \
src/e_scalbf.c \
src/e_sinh.c \
src/e_sinhf.c \
src/e_sqrt.c \
src/k_cos.c \
src/k_cosf.c \
src/k_rem_pio2.c \
src/k_sin.c \
src/k_sinf.c \
src/k_tan.c \
src/k_tanf.c \
src/s_asinh.c \
src/s_asinhf.c \
src/s_atan.c \
src/s_atanf.c \
src/s_cbrt.c \
src/s_cbrtf.c \
src/s_ceil.c \
src/s_ceilf.c \
src/s_ceill.c \
src/s_copysign.c \
src/s_copysignf.c \
src/s_cos.c \
src/s_cosf.c \
src/s_erf.c \
src/s_erff.c \
src/s_exp2.c \
src/s_exp2f.c \
src/s_expm1.c \
src/s_expm1f.c \
src/s_fabsf.c \
src/s_fdim.c \
src/s_finite.c \
src/s_finitef.c \
src/s_floor.c \
src/s_floorf.c \
src/s_floorl.c \
src/s_fma.c \
src/s_fmaf.c \
src/s_fmax.c \
src/s_fmaxf.c \
src/s_fmaxl.c \
src/s_fmin.c \
src/s_fminf.c \
src/s_fminl.c \
src/s_frexpf.c \
src/s_ilogb.c \
src/s_ilogbf.c \
src/s_ilogbl.c \
src/s_isfinite.c \
src/s_isnormal.c \
src/s_llrint.c \
src/s_llrintf.c \
src/s_llround.c \
src/s_llroundf.c \
src/s_llroundl.c \
src/s_log1p.c \
src/s_log1pf.c \
src/s_logb.c \
src/s_logbf.c \
src/s_lrint.c \
src/s_lrintf.c \
src/s_lround.c \
src/s_lroundf.c \
src/s_lroundl.c \
src/s_modff.c \
src/s_nan.c \
src/s_nearbyint.c \
src/s_nextafter.c \
src/s_nextafterf.c \
src/s_nexttowardf.c \
src/s_remquo.c \
src/s_remquof.c \
src/s_rint.c \
src/s_rintf.c \
src/s_round.c \
src/s_roundf.c \
src/s_roundl.c \
src/s_signbit.c \
src/s_signgam.c \
src/s_significand.c \
src/s_significandf.c \
src/s_sin.c \
src/s_sinf.c \
src/s_tan.c \
src/s_tanf.c \
src/s_tanh.c \
src/s_tanhf.c \
src/s_tgammaf.c \
src/s_trunc.c \
src/s_truncf.c \
src/s_truncl.c \
src/w_drem.c \
src/w_dremf.c \
src/s_copysignl.c \
src/s_fabsl.c \
src/s_fabs.c \
src/s_frexp.c \
src/s_isnan.c \
src/s_modf.c
# TODO: these come from from upstream's libc, not libm!
libm_common_src_files := \
digittoint.c \
fpclassify.c \
isinf.c \
libm_common_cflags :=
# TODO: this is not in the BSDs.
libm_common_src_files += \
sincos.c \
ifeq ($(TARGET_ARCH),arm)
libm_common_src_files += \
arm/fenv.c \
src/e_ldexpf.c \
src/s_scalbln.c \
src/s_scalbn.c \
src/s_scalbnf.c \
src/e_sqrtf.c
libm_common_src_files += \
upstream-freebsd/lib/msun/bsdsrc/b_exp.c \
upstream-freebsd/lib/msun/bsdsrc/b_log.c \
upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c \
upstream-freebsd/lib/msun/src/e_acos.c \
upstream-freebsd/lib/msun/src/e_acosf.c \
upstream-freebsd/lib/msun/src/e_acosh.c \
upstream-freebsd/lib/msun/src/e_acoshf.c \
upstream-freebsd/lib/msun/src/e_asin.c \
upstream-freebsd/lib/msun/src/e_asinf.c \
upstream-freebsd/lib/msun/src/e_atan2.c \
upstream-freebsd/lib/msun/src/e_atan2f.c \
upstream-freebsd/lib/msun/src/e_atanh.c \
upstream-freebsd/lib/msun/src/e_atanhf.c \
upstream-freebsd/lib/msun/src/e_cosh.c \
upstream-freebsd/lib/msun/src/e_coshf.c \
upstream-freebsd/lib/msun/src/e_exp.c \
upstream-freebsd/lib/msun/src/e_expf.c \
upstream-freebsd/lib/msun/src/e_fmod.c \
upstream-freebsd/lib/msun/src/e_fmodf.c \
upstream-freebsd/lib/msun/src/e_gamma.c \
upstream-freebsd/lib/msun/src/e_gammaf.c \
upstream-freebsd/lib/msun/src/e_gammaf_r.c \
upstream-freebsd/lib/msun/src/e_gamma_r.c \
upstream-freebsd/lib/msun/src/e_hypot.c \
upstream-freebsd/lib/msun/src/e_hypotf.c \
upstream-freebsd/lib/msun/src/e_j0.c \
upstream-freebsd/lib/msun/src/e_j0f.c \
upstream-freebsd/lib/msun/src/e_j1.c \
upstream-freebsd/lib/msun/src/e_j1f.c \
upstream-freebsd/lib/msun/src/e_jn.c \
upstream-freebsd/lib/msun/src/e_jnf.c \
upstream-freebsd/lib/msun/src/e_lgamma.c \
upstream-freebsd/lib/msun/src/e_lgammaf.c \
upstream-freebsd/lib/msun/src/e_lgammaf_r.c \
upstream-freebsd/lib/msun/src/e_lgamma_r.c \
upstream-freebsd/lib/msun/src/e_log10.c \
upstream-freebsd/lib/msun/src/e_log10f.c \
upstream-freebsd/lib/msun/src/e_log2.c \
upstream-freebsd/lib/msun/src/e_log2f.c \
upstream-freebsd/lib/msun/src/e_log.c \
upstream-freebsd/lib/msun/src/e_logf.c \
upstream-freebsd/lib/msun/src/e_pow.c \
upstream-freebsd/lib/msun/src/e_powf.c \
upstream-freebsd/lib/msun/src/e_remainder.c \
upstream-freebsd/lib/msun/src/e_remainderf.c \
upstream-freebsd/lib/msun/src/e_rem_pio2.c \
upstream-freebsd/lib/msun/src/e_rem_pio2f.c \
upstream-freebsd/lib/msun/src/e_scalb.c \
upstream-freebsd/lib/msun/src/e_scalbf.c \
upstream-freebsd/lib/msun/src/e_sinh.c \
upstream-freebsd/lib/msun/src/e_sinhf.c \
upstream-freebsd/lib/msun/src/e_sqrt.c \
upstream-freebsd/lib/msun/src/e_sqrtf.c \
upstream-freebsd/lib/msun/src/k_cos.c \
upstream-freebsd/lib/msun/src/k_cosf.c \
upstream-freebsd/lib/msun/src/k_exp.c \
upstream-freebsd/lib/msun/src/k_expf.c \
upstream-freebsd/lib/msun/src/k_rem_pio2.c \
upstream-freebsd/lib/msun/src/k_sin.c \
upstream-freebsd/lib/msun/src/k_sinf.c \
upstream-freebsd/lib/msun/src/k_tan.c \
upstream-freebsd/lib/msun/src/k_tanf.c \
upstream-freebsd/lib/msun/src/s_asinh.c \
upstream-freebsd/lib/msun/src/s_asinhf.c \
upstream-freebsd/lib/msun/src/s_atan.c \
upstream-freebsd/lib/msun/src/s_atanf.c \
upstream-freebsd/lib/msun/src/s_carg.c \
upstream-freebsd/lib/msun/src/s_cargf.c \
upstream-freebsd/lib/msun/src/s_cbrt.c \
upstream-freebsd/lib/msun/src/s_cbrtf.c \
upstream-freebsd/lib/msun/src/s_ccosh.c \
upstream-freebsd/lib/msun/src/s_ccoshf.c \
upstream-freebsd/lib/msun/src/s_ceil.c \
upstream-freebsd/lib/msun/src/s_ceilf.c \
upstream-freebsd/lib/msun/src/s_cexp.c \
upstream-freebsd/lib/msun/src/s_cexpf.c \
upstream-freebsd/lib/msun/src/s_cimag.c \
upstream-freebsd/lib/msun/src/s_cimagf.c \
upstream-freebsd/lib/msun/src/s_conj.c \
upstream-freebsd/lib/msun/src/s_conjf.c \
upstream-freebsd/lib/msun/src/s_copysign.c \
upstream-freebsd/lib/msun/src/s_copysignf.c \
upstream-freebsd/lib/msun/src/s_cos.c \
upstream-freebsd/lib/msun/src/s_cosf.c \
upstream-freebsd/lib/msun/src/s_cproj.c \
upstream-freebsd/lib/msun/src/s_cprojf.c \
upstream-freebsd/lib/msun/src/s_creal.c \
upstream-freebsd/lib/msun/src/s_crealf.c \
upstream-freebsd/lib/msun/src/s_csinh.c \
upstream-freebsd/lib/msun/src/s_csinhf.c \
upstream-freebsd/lib/msun/src/s_csqrt.c \
upstream-freebsd/lib/msun/src/s_csqrtf.c \
upstream-freebsd/lib/msun/src/s_ctanh.c \
upstream-freebsd/lib/msun/src/s_ctanhf.c \
upstream-freebsd/lib/msun/src/s_erf.c \
upstream-freebsd/lib/msun/src/s_erff.c \
upstream-freebsd/lib/msun/src/s_exp2.c \
upstream-freebsd/lib/msun/src/s_exp2f.c \
upstream-freebsd/lib/msun/src/s_expm1.c \
upstream-freebsd/lib/msun/src/s_expm1f.c \
upstream-freebsd/lib/msun/src/s_fabs.c \
upstream-freebsd/lib/msun/src/s_fabsf.c \
upstream-freebsd/lib/msun/src/s_fdim.c \
upstream-freebsd/lib/msun/src/s_finite.c \
upstream-freebsd/lib/msun/src/s_finitef.c \
upstream-freebsd/lib/msun/src/s_floor.c \
upstream-freebsd/lib/msun/src/s_floorf.c \
upstream-freebsd/lib/msun/src/s_fma.c \
upstream-freebsd/lib/msun/src/s_fmaf.c \
upstream-freebsd/lib/msun/src/s_fmax.c \
upstream-freebsd/lib/msun/src/s_fmaxf.c \
upstream-freebsd/lib/msun/src/s_fmin.c \
upstream-freebsd/lib/msun/src/s_fminf.c \
upstream-freebsd/lib/msun/src/s_frexp.c \
upstream-freebsd/lib/msun/src/s_frexpf.c \
upstream-freebsd/lib/msun/src/s_ilogb.c \
upstream-freebsd/lib/msun/src/s_ilogbf.c \
upstream-freebsd/lib/msun/src/s_isfinite.c \
upstream-freebsd/lib/msun/src/s_isnan.c \
upstream-freebsd/lib/msun/src/s_isnormal.c \
upstream-freebsd/lib/msun/src/s_llrint.c \
upstream-freebsd/lib/msun/src/s_llrintf.c \
upstream-freebsd/lib/msun/src/s_llround.c \
upstream-freebsd/lib/msun/src/s_llroundf.c \
upstream-freebsd/lib/msun/src/s_log1p.c \
upstream-freebsd/lib/msun/src/s_log1pf.c \
upstream-freebsd/lib/msun/src/s_logb.c \
upstream-freebsd/lib/msun/src/s_logbf.c \
upstream-freebsd/lib/msun/src/s_lrint.c \
upstream-freebsd/lib/msun/src/s_lrintf.c \
upstream-freebsd/lib/msun/src/s_lround.c \
upstream-freebsd/lib/msun/src/s_lroundf.c \
upstream-freebsd/lib/msun/src/s_modf.c \
upstream-freebsd/lib/msun/src/s_modff.c \
upstream-freebsd/lib/msun/src/s_nan.c \
upstream-freebsd/lib/msun/src/s_nearbyint.c \
upstream-freebsd/lib/msun/src/s_nextafter.c \
upstream-freebsd/lib/msun/src/s_nextafterf.c \
upstream-freebsd/lib/msun/src/s_nexttowardf.c \
upstream-freebsd/lib/msun/src/s_remquo.c \
upstream-freebsd/lib/msun/src/s_remquof.c \
upstream-freebsd/lib/msun/src/s_rint.c \
upstream-freebsd/lib/msun/src/s_rintf.c \
upstream-freebsd/lib/msun/src/s_round.c \
upstream-freebsd/lib/msun/src/s_roundf.c \
upstream-freebsd/lib/msun/src/s_scalbln.c \
upstream-freebsd/lib/msun/src/s_scalbn.c \
upstream-freebsd/lib/msun/src/s_scalbnf.c \
upstream-freebsd/lib/msun/src/s_signbit.c \
upstream-freebsd/lib/msun/src/s_signgam.c \
upstream-freebsd/lib/msun/src/s_significand.c \
upstream-freebsd/lib/msun/src/s_significandf.c \
upstream-freebsd/lib/msun/src/s_sin.c \
upstream-freebsd/lib/msun/src/s_sinf.c \
upstream-freebsd/lib/msun/src/s_tan.c \
upstream-freebsd/lib/msun/src/s_tanf.c \
upstream-freebsd/lib/msun/src/s_tanh.c \
upstream-freebsd/lib/msun/src/s_tanhf.c \
upstream-freebsd/lib/msun/src/s_tgammaf.c \
upstream-freebsd/lib/msun/src/s_trunc.c \
upstream-freebsd/lib/msun/src/s_truncf.c \
upstream-freebsd/lib/msun/src/w_cabs.c \
upstream-freebsd/lib/msun/src/w_cabsf.c \
upstream-freebsd/lib/msun/src/w_drem.c \
upstream-freebsd/lib/msun/src/w_dremf.c \
libm_common_includes = $(LOCAL_PATH)/arm
endif
libm_common_src_files += fake_long_double.c
ifeq ($(TARGET_OS)-$(TARGET_ARCH),linux-x86)
libm_common_src_files += \
i387/fenv.c \
i387/s_scalbnl.S \
i387/s_scalbn.S \
i387/s_scalbnf.S \
i387/e_sqrtf.S
# TODO: on Android, "long double" is "double".
# upstream-freebsd/lib/msun/src/e_acosl.c \
# upstream-freebsd/lib/msun/src/e_asinl.c \
# upstream-freebsd/lib/msun/src/e_atan2l.c \
# upstream-freebsd/lib/msun/src/e_fmodl.c \
# upstream-freebsd/lib/msun/src/e_hypotl.c \
# upstream-freebsd/lib/msun/src/e_remainderl.c \
# upstream-freebsd/lib/msun/src/e_sqrtl.c \
# upstream-freebsd/lib/msun/src/s_atanl.c \
# upstream-freebsd/lib/msun/src/s_cbrtl.c \
# upstream-freebsd/lib/msun/src/s_ceill.c \
# upstream-freebsd/lib/msun/src/s_copysignl.c \
# upstream-freebsd/lib/msun/src/s_cosl.c \
# upstream-freebsd/lib/msun/src/s_fabsl.c \
# upstream-freebsd/lib/msun/src/s_floorl.c \
# upstream-freebsd/lib/msun/src/s_fmal.c \
# upstream-freebsd/lib/msun/src/s_fmaxl.c \
# upstream-freebsd/lib/msun/src/s_fminl.c \
# upstream-freebsd/lib/msun/src/s_frexpl.c \
# upstream-freebsd/lib/msun/src/s_ilogbl.c \
# upstream-freebsd/lib/msun/src/s_llrintl.c \
# upstream-freebsd/lib/msun/src/s_llroundl.c \
# upstream-freebsd/lib/msun/src/s_logbl.c \
# upstream-freebsd/lib/msun/src/s_lrintl.c \
# upstream-freebsd/lib/msun/src/s_lroundl.c \
# upstream-freebsd/lib/msun/src/s_modfl.c \
# upstream-freebsd/lib/msun/src/s_nextafterl.c \
# upstream-freebsd/lib/msun/src/s_nexttoward.c \
# upstream-freebsd/lib/msun/src/s_remquol.c \
# upstream-freebsd/lib/msun/src/s_rintl.c \
# upstream-freebsd/lib/msun/src/s_roundl.c \
# upstream-freebsd/lib/msun/src/s_scalbnl.c \
# upstream-freebsd/lib/msun/src/s_sinl.c \
# upstream-freebsd/lib/msun/src/s_tanl.c \
# upstream-freebsd/lib/msun/src/s_truncl.c \
libm_common_includes = $(LOCAL_PATH)/i386 $(LOCAL_PATH)/i387
endif
ifeq ($(TARGET_ARCH),mips)
libm_common_src_files += \
mips/fenv.c \
src/e_ldexpf.c \
src/s_scalbln.c \
src/s_scalbn.c \
src/s_scalbnf.c \
src/e_sqrtf.c
# TODO: re-enable i387/e_sqrtf.S for x86, and maybe others.
libm_common_includes = $(LOCAL_PATH)/mips
# Need to build *rint* functions
libm_common_cflags += -fno-builtin-rintf -fno-builtin-rint
endif
libm_common_cflags := -DFLT_EVAL_METHOD=0
libm_common_includes := $(LOCAL_PATH)/upstream-freebsd/lib/msun/src/
# libm.a
# ========================================================
libm_arm_includes := $(LOCAL_PATH)/arm
libm_arm_src_files := arm/fenv.c
libm_x86_includes := $(LOCAL_PATH)/i386 $(LOCAL_PATH)/i387
libm_x86_src_files := i387/fenv.c
libm_mips_cflags := -fno-builtin-rintf -fno-builtin-rint
libm_mips_includes := $(LOCAL_PATH)/mips
libm_mips_src_files := mips/fenv.c
#
# libm.a for target.
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(libm_common_src_files)
LOCAL_ARM_MODE := arm
LOCAL_C_INCLUDES += $(libm_common_includes)
LOCAL_CFLAGS := $(libm_common_cflags)
LOCAL_MODULE:= libm
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_ARM_MODE := arm
LOCAL_CFLAGS := $(libm_common_cflags) $(libm_$(TARGET_ARCH)_cflags)
LOCAL_C_INCLUDES += $(libm_common_includes) $(libm_$(TARGET_ARCH)_includes)
LOCAL_SRC_FILES := $(libm_common_src_files) $(libm_$(TARGET_ARCH)_src_files)
LOCAL_SYSTEM_SHARED_LIBRARIES := libc
include $(BUILD_STATIC_LIBRARY)
# libm.so
# ========================================================
#
# libm.so for target.
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(libm_common_src_files)
LOCAL_ARM_MODE := arm
LOCAL_C_INCLUDES += $(libm_common_includes)
LOCAL_CFLAGS := $(libm_common_cflags)
LOCAL_MODULE:= libm
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_SYSTEM_SHARED_LIBRARIES := libc
LOCAL_WHOLE_STATIC_LIBRARIES := libm
include $(BUILD_SHARED_LIBRARY)

View File

@ -23,18 +23,29 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/lib/libc/arm/_fpmath.h,v 1.4 2005/03/20 00:53:52 cognet Exp $
* $FreeBSD$
*/
#if defined(__VFP_FP__)
#define _IEEE_WORD_ORDER _BYTE_ORDER
#else
#define _IEEE_WORD_ORDER _BIG_ENDIAN
#endif
union IEEEl2bits {
long double e;
struct {
#ifndef __ARMEB__
#if _BYTE_ORDER == _LITTLE_ENDIAN
#if _IEEE_WORD_ORDER == _LITTLE_ENDIAN
unsigned int manl :32;
#endif
unsigned int manh :20;
unsigned int exp :11;
unsigned int sign :1;
#else
#if _IEEE_WORD_ORDER == _BIG_ENDIAN
unsigned int manl :32;
#endif
#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
unsigned int sign :1;
unsigned int exp :11;
unsigned int manh :20;
@ -44,9 +55,10 @@ union IEEEl2bits {
};
#define LDBL_NBIT 0
#define LDBL_IMPLICIT_NBIT
#define mask_nbit_l(u) ((void)0)
#define LDBL_MANH_SIZE 32
#define LDBL_MANH_SIZE 20
#define LDBL_MANL_SIZE 32
#define LDBL_TO_ARRAY32(u, a) do { \

46
libm/digittoint.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$
*/
#include <sys/cdefs.h>
/* digittoint is in the FreeBSD C library, but implemented in terms of locale stuff. */
__LIBC_HIDDEN__ int digittoint(char ch) {
int d = ch - '0';
if ((unsigned) d < 10) {
return d;
}
d = ch - 'a';
if ((unsigned) d < 6) {
return d + 10;
}
d = ch - 'A';
if ((unsigned) d < 6) {
return d + 10;
}
return -1;
}

68
libm/fake_long_double.c Normal file
View File

@ -0,0 +1,68 @@
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <float.h>
#include <math.h>
extern int __isinf(double); /* isinf.c */
int (isinf)(double a1) { return __isinf(a1); }
/*
* The BSD "long double" functions are broken when sizeof(long double) == sizeof(double).
* Android works around those cases by replacing the broken functions with our own trivial stubs
* that call the regular "double" function.
*/
int __fpclassifyl(long double a1) { return __fpclassifyd(a1); }
int __isfinitel(long double a1) { return __isfinite(a1); }
int __isinfl(long double a1) { return __isinf(a1); }
int __isnanl(long double a1) { return isnan(a1); }
int __isnormall(long double a1) { return __isnormal(a1); }
int __signbitl(long double a1) { return __signbit(a1); }
long double acoshl(long double a1) { return acosh(a1); }
long double asinhl(long double a1) { return asinh(a1); }
long double atanhl(long double a1) { return atanh(a1); }
long double cbrtl(long double a1) { return cbrt(a1); }
long double copysignl(long double a1, long double a2) { return copysign(a1, a2); }
long double coshl(long double a1) { return cosh(a1); }
long double erfcl(long double a1) { return erfc(a1); }
long double erfl(long double a1) { return erf(a1); }
long double expm1l(long double a1) { return expm1(a1); }
long double fabsl(long double a1) { return fabs(a1); }
long double fmaxl(long double a1, long double a2) { return fmax(a1, a2); }
long double fmodl(long double a1, long double a2) { return fmod(a1, a2); }
long double fminl(long double a1, long double a2) { return fmin(a1, a2); }
int ilogbl(long double a1) { return ilogb(a1); }
long double lgammal(long double a1) { return lgamma(a1); }
long long llrintl(long double a1) { return llrint(a1); }
long double log10l(long double a1) { return log10(a1); }
long double log1pl(long double a1) { return log1p(a1); }
long double log2l(long double a1) { return log2(a1); }
long double logl(long double a1) { return log(a1); }
long lrintl(long double a1) { return lrint(a1); }
long long llroundl(long double a1) { return llround(a1); }
long lroundl(long double a1) { return lround(a1); }
long double modfl(long double a1, long double* a2) { return modf(a1, (double*) a2); }
long double powl(long double a1, long double a2) { return pow(a1, a2); }
long double rintl(long double a1) { return rint(a1); }
long double roundl(long double a1) { return round(a1); }
long double scalbnl(long double a1, int a2) { return scalbn(a1, a2); }
long double significandl(long double a1) { return significand(a1); }
long double sinhl(long double a1) { return sinh(a1); }
long double sqrtl(long double a1) { return sqrt(a1); }
long double tanhl(long double a1) { return tanh(a1); }
long double tgammal(long double a1) { return tgamma(a1); }

View File

@ -32,7 +32,7 @@
#include <math.h>
#include <stdint.h>
#include "src/fpmath.h"
#include "fpmath.h"
int
__fpclassifyf(float f)

View File

@ -57,7 +57,7 @@ union IEEEd2bits {
unsigned int exp :11;
unsigned int sign :1;
unsigned int manl :32;
#elif __BYTE_ORDER == __LITTLE_ENDIAN
#elif __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int manl :32;
unsigned int manh :20;
unsigned int exp :11;
@ -70,3 +70,15 @@ union IEEEd2bits {
#endif
} bits;
};
/*
* The BSD "long double" functions are broken when sizeof(long double) == sizeof(double).
* Android works around those cases by replacing the broken functions with our own trivial stubs
* that call the regular "double" function.
*/
#define __fpclassifyl __broken__fpclassify
#define __isfinitel __broken__isfinitel
#define __isinfl __broken__isinfl
#define __isnanl __broken__isnanl
#define __isnormall __broken__isnormall
#define __signbitl __broken_signbitl

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/libc/i386/_fpmath.h,v 1.5 2005/03/07 04:55:22 das Exp $
* $FreeBSD$
*/
union IEEEl2bits {
@ -35,6 +35,11 @@ union IEEEl2bits {
unsigned int sign :1;
unsigned int junk :16;
} bits;
struct {
unsigned long long man :64;
unsigned int expsign :16;
unsigned int junk :16;
} xbits;
};
#define LDBL_NBIT 0x80000000
@ -46,4 +51,4 @@ union IEEEl2bits {
#define LDBL_TO_ARRAY32(u, a) do { \
(a)[0] = (uint32_t)(u).bits.manl; \
(a)[1] = (uint32_t)(u).bits.manh; \
} while(0)
} while (0)

92
libm/include/complex.h Normal file
View File

@ -0,0 +1,92 @@
/*-
* Copyright (c) 2001-2011 The FreeBSD Project.
* 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$
*/
#ifndef _COMPLEX_H
#define _COMPLEX_H
#include <sys/cdefs.h>
#ifdef __GNUC__
#if __STDC_VERSION__ < 199901
#define _Complex __complex__
#endif
#define _Complex_I ((float _Complex)1.0i)
#endif
#ifdef __generic
_Static_assert(__generic(_Complex_I, float _Complex, 1, 0),
"_Complex_I must be of type float _Complex");
#endif
#define complex _Complex
#define I _Complex_I
__BEGIN_DECLS
double cabs(double complex);
float cabsf(float complex);
long double cabsl(long double complex);
double carg(double complex);
float cargf(float complex);
long double cargl(long double complex);
double complex ccos(double complex);
float complex ccosf(float complex);
double complex ccosh(double complex);
float complex ccoshf(float complex);
double complex cexp(double complex);
float complex cexpf(float complex);
double cimag(double complex) __pure2;
float cimagf(float complex) __pure2;
long double cimagl(long double complex) __pure2;
double complex conj(double complex) __pure2;
float complex conjf(float complex) __pure2;
long double complex
conjl(long double complex) __pure2;
float complex cprojf(float complex) __pure2;
double complex cproj(double complex) __pure2;
long double complex
cprojl(long double complex) __pure2;
double creal(double complex) __pure2;
float crealf(float complex) __pure2;
long double creall(long double complex) __pure2;
double complex csin(double complex);
float complex csinf(float complex);
double complex csinh(double complex);
float complex csinhf(float complex);
double complex csqrt(double complex);
float complex csqrtf(float complex);
long double complex
csqrtl(long double complex);
double complex ctan(double complex);
float complex ctanf(float complex);
double complex ctanh(double complex);
float complex ctanhf(float complex);
__END_DECLS
#endif /* _COMPLEX_H */

View File

@ -11,18 +11,16 @@
/*
* from: @(#)fdlibm.h 5.1 93/09/24
* $FreeBSD: src/lib/msun/src/math.h,v 1.61 2005/04/16 21:12:47 das Exp $
* $FreeBSD$
*/
#ifndef _MATH_H_
#define _MATH_H_
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/_types.h>
#include <limits.h>
#define __pure2
/*
* ANSI/POSIX
*/
@ -36,37 +34,29 @@ extern const union __nan_un {
float __uf;
} __nan;
/* #if __GNUC_PREREQ__(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800) */
#if 1
#if __GNUC_PREREQ__(3, 3) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
#define __MATH_BUILTIN_CONSTANTS
#endif
/* #if __GNUC_PREREQ__(3, 0) && !defined(__INTEL_COMPILER) */
#if 1
#if __GNUC_PREREQ__(3, 0) && !defined(__INTEL_COMPILER)
#define __MATH_BUILTIN_RELOPS
#endif
/* #ifdef __MATH_BUILTIN_CONSTANTS */
#if 1
#ifdef __MATH_BUILTIN_CONSTANTS
#define HUGE_VAL __builtin_huge_val()
#else
#define HUGE_VAL (__infinity.__ud)
#endif
/* #if __ISO_C_VISIBLE >= 1999 */
#if 0
#define FP_ILOGB0 (-__INT_MAX)
#define FP_ILOGBNAN __INT_MAX
#else
#define FP_ILOGB0 (-INT_MAX)
#define FP_ILOGBNAN INT_MAX
#endif
#if __ISO_C_VISIBLE >= 1999
#define FP_ILOGB0 (-INT_MAX) /* Android-changed */
#define FP_ILOGBNAN INT_MAX /* Android-changed */
#ifdef __MATH_BUILTIN_CONSTANTS
#define HUGE_VALF __builtin_huge_valf()
#define HUGE_VALL __builtin_huge_vall()
#define INFINITY __builtin_inf()
#define NAN __builtin_nan("")
#define INFINITY __builtin_inff()
#define NAN __builtin_nanf("")
#else
#define HUGE_VALF (float)HUGE_VAL
#define HUGE_VALL (long double)HUGE_VAL
@ -78,14 +68,11 @@ extern const union __nan_un {
#define MATH_ERREXCEPT 2
#define math_errhandling MATH_ERREXCEPT
/* XXX We need a <machine/math.h>. */
#if defined(__ia64__) || defined(__sparc64__)
#define FP_FAST_FMA
#endif
#define FP_FAST_FMAF 1
#ifdef __ia64__
#define FP_FAST_FMAL
#define FP_FAST_FMA 1
#define FP_FAST_FMAL 1
#endif
#define FP_FAST_FMAF
/* Symbolic constants to classify floating point numbers. */
#define FP_INFINITE 0x01
@ -104,10 +91,10 @@ extern const union __nan_un {
: __isfinitel(x))
#define isinf(x) \
((sizeof (x) == sizeof (float)) ? __isinff(x) \
: (sizeof (x) == sizeof (double)) ? __isinf(x) \
: (sizeof (x) == sizeof (double)) ? isinf(x) \
: __isinfl(x))
#define isnan(x) \
((sizeof (x) == sizeof (float)) ? isnanf(x) \
((sizeof (x) == sizeof (float)) ? __isnanf(x) \
: (sizeof (x) == sizeof (double)) ? isnan(x) \
: __isnanl(x))
#define isnormal(x) \
@ -137,16 +124,14 @@ extern const union __nan_un {
: (sizeof (x) == sizeof (double)) ? __signbit(x) \
: __signbitl(x))
#if 0
typedef __double_t double_t;
typedef __float_t float_t;
#endif
/* #endif */ /* __ISO_C_VISIBLE >= 1999 */
#endif /* __ISO_C_VISIBLE >= 1999 */
/*
* XOPEN/SVID
*/
/* #if __BSD_VISIBLE || __XSI_VISIBLE */
#if __BSD_VISIBLE || __XSI_VISIBLE
#define M_E 2.7182818284590452354 /* e */
#define M_LOG2E 1.4426950408889634074 /* log 2e */
#define M_LOG10E 0.43429448190325182765 /* log 10e */
@ -163,7 +148,7 @@ typedef __float_t float_t;
#define MAXFLOAT ((float)3.40282346638528860e+38)
extern int signgam;
/* #endif */ /* __BSD_VISIBLE || __XSI_VISIBLE */
#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
#if __BSD_VISIBLE
#if 0
@ -190,8 +175,8 @@ int __isfinitef(float) __pure2;
int __isfinite(double) __pure2;
int __isfinitel(long double) __pure2;
int __isinff(float) __pure2;
int __isinf(double) __pure2;
int __isinfl(long double) __pure2;
int __isnanf(float) __pure2;
int __isnanl(long double) __pure2;
int __isnormalf(float) __pure2;
int __isnormal(double) __pure2;
@ -230,7 +215,7 @@ double fmod(double, double);
/*
* These functions are not in C90.
*/
/* #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE
double acosh(double);
double asinh(double);
double atanh(double);
@ -242,12 +227,13 @@ double expm1(double);
double fma(double, double, double);
double hypot(double, double);
int ilogb(double) __pure2;
/* int (isinf)(double) __pure2; */
int (isinf)(double) __pure2;
int (isnan)(double) __pure2;
double lgamma(double);
long long llrint(double);
long long llround(double);
double log1p(double);
double log2(double);
double logb(double);
long lrint(double);
long lround(double);
@ -256,23 +242,26 @@ double nextafter(double, double);
double remainder(double, double);
double remquo(double, double, int *);
double rint(double);
/* #endif */ /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
#endif /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */
/* #if __BSD_VISIBLE || __XSI_VISIBLE */
#if __BSD_VISIBLE || __XSI_VISIBLE
double j0(double);
double j1(double);
double jn(int, double);
double scalb(double, double);
double y0(double);
double y1(double);
double yn(int, double);
/* #if __XSI_VISIBLE <= 500 || __BSD_VISIBLE */
#if __XSI_VISIBLE <= 500 || __BSD_VISIBLE
double gamma(double);
/* #endif */
/* #endif */ /* __BSD_VISIBLE || __XSI_VISIBLE */
#endif
/* #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 */
#if __XSI_VISIBLE <= 600 || __BSD_VISIBLE
double scalb(double, double);
#endif
#endif /* __BSD_VISIBLE || __XSI_VISIBLE */
#if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999
double copysign(double, double) __pure2;
double fdim(double, double);
double fmax(double, double) __pure2;
@ -283,12 +272,12 @@ double scalbln(double, long);
double scalbn(double, int);
double tgamma(double);
double trunc(double);
/* #endif */
#endif
/*
* BSD math library entry points
*/
/* #if __BSD_VISIBLE */
#if __BSD_VISIBLE
double drem(double, double);
int finite(double) __pure2;
int isnanf(float) __pure2;
@ -304,10 +293,10 @@ double lgamma_r(double, int *);
* IEEE Test Vector
*/
double significand(double);
/* #endif */ /* __BSD_VISIBLE */
#endif /* __BSD_VISIBLE */
/* float versions of ANSI/POSIX functions */
/*#if __ISO_C_VISIBLE >= 1999 */
#if __ISO_C_VISIBLE >= 1999
float acosf(float);
float asinf(float);
float atanf(float);
@ -328,6 +317,7 @@ int ilogbf(float) __pure2;
float ldexpf(float, int);
float log10f(float);
float log1pf(float);
float log2f(float);
float logf(float);
float modff(float, float *); /* fundamentally !__pure2 */
@ -370,12 +360,12 @@ float fdimf(float, float);
float fmaf(float, float, float);
float fmaxf(float, float) __pure2;
float fminf(float, float) __pure2;
/* #endif */
#endif
/*
* float versions of BSD math library entry points
*/
/* #if __BSD_VISIBLE */
#if __BSD_VISIBLE
float dremf(float, float);
int finitef(float) __pure2;
float gammaf(float);
@ -399,98 +389,92 @@ float lgammaf_r(float, int *);
* float version of IEEE Test Vector
*/
float significandf(float);
/* #endif */ /* __BSD_VISIBLE */
#endif /* __BSD_VISIBLE */
/*
* long double versions of ISO/POSIX math functions
*/
/* #if __ISO_C_VISIBLE >= 1999 */
#if 0
long double acoshl(long double);
#if __ISO_C_VISIBLE >= 1999
long double acosl(long double);
long double asinhl(long double);
long double asinl(long double);
long double atan2l(long double, long double);
long double atanhl(long double);
long double atanl(long double);
long double cbrtl(long double);
#endif
long double ceill(long double);
long double copysignl(long double, long double) __pure2;
#if 0
long double coshl(long double);
long double cosl(long double);
long double erfcl(long double);
long double erfl(long double);
long double exp2l(long double);
long double expl(long double);
long double expm1l(long double);
#endif
long double fabsl(long double) __pure2;
long double fdiml(long double, long double);
long double floorl(long double);
long double fmal(long double, long double, long double);
long double fmaxl(long double, long double) __pure2;
long double fminl(long double, long double) __pure2;
#if 0
long double fmodl(long double, long double);
#endif
long double frexpl(long double value, int *); /* fundamentally !__pure2 */
#if 0
long double hypotl(long double, long double);
#endif
int ilogbl(long double) __pure2;
long double ldexpl(long double, int);
#if 0
long double lgammal(long double);
long long llrintl(long double);
#endif
long long llroundl(long double);
#if 0
long double log10l(long double);
long double log1pl(long double);
long double log2l(long double);
long double logbl(long double);
long double logl(long double);
long lrintl(long double);
#endif
long lroundl(long double);
#if 0
long double modfl(long double, long double *); /* fundamentally !__pure2 */
long double nanl(const char *) __pure2;
long double nearbyintl(long double);
#endif
long double nextafterl(long double, long double);
double nexttoward(double, long double);
float nexttowardf(float, long double);
long double nexttowardl(long double, long double);
#if 0
long double powl(long double, long double);
long double remainderl(long double, long double);
long double remquol(long double, long double, int *);
long double rintl(long double);
#endif
long double roundl(long double);
long double scalblnl(long double, long);
long double scalbnl(long double, int);
#if 0
long double sinhl(long double);
long double sinl(long double);
long double sqrtl(long double);
long double tanhl(long double);
long double tanl(long double);
long double tgammal(long double);
#endif
long double truncl(long double);
/* BIONIC: GLibc compatibility - required by the ARM toolchain */
#ifdef _GNU_SOURCE
void sincos(double x, double *sin, double *cos);
void sincosf(float x, float *sin, float *cos);
void sincosl(long double x, long double *sin, long double *cos);
#endif
/* #endif */ /* __ISO_C_VISIBLE >= 1999 */
#endif /* __ISO_C_VISIBLE >= 1999 */
__END_DECLS
#endif /* !_MATH_H_ */
/* separate header for cmath */
#ifndef _MATH_EXTRA_H_
#if __ISO_C_VISIBLE >= 1999
#if _DECLARE_C99_LDBL_MATH
#define _MATH_EXTRA_H_
/*
* extra long double versions of math functions for C99 and cmath
*/
__BEGIN_DECLS
long double acoshl(long double);
long double asinhl(long double);
long double atanhl(long double);
long double coshl(long double);
long double erfcl(long double);
long double erfl(long double);
long double expm1l(long double);
long double lgammal(long double);
long double log10l(long double);
long double log1pl(long double);
long double log2l(long double);
long double logl(long double);
long double powl(long double, long double);
long double sinhl(long double);
long double tanhl(long double);
long double tgammal(long double);
__END_DECLS
#endif /* !_DECLARE_C99_LDBL_MATH */
#endif /* __ISO_C_VISIBLE >= 1999 */
#endif /* !_MATH_EXTRA_H_ */

View File

@ -28,7 +28,7 @@
#include <math.h>
#include <sys/cdefs.h>
#include "src/fpmath.h"
#include "fpmath.h"
/*
* XXX These routines belong in libm, but they must remain in libc for
@ -66,4 +66,3 @@ __isinfl(long double e)
return (u.bits.exp == 2047 && u.bits.manl == 0 && u.bits.manh == 0);
#endif
}

View File

@ -1,92 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.13 2005/01/14 23:28:28 das Exp $
.\"
.Dd January 14, 2005
.Dt ACOS 3
.Os
.Sh NAME
.Nm acos ,
.Nm acosf
.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"
.Sh DESCRIPTION
The
.Fn acos
and the
.Fn acosf
functions compute the principal value of the arc cosine of
.Fa x .
A domain error occurs for arguments not in the range
.Bq -1 , +1 .
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
The
.Fn acos
and the
.Fn acosf
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
function conforms to
.St -isoC .

View File

@ -1,82 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.11 2005/01/14 23:28:28 das 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 .

View File

@ -1,94 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.15 2005/01/14 23:28:28 das Exp $
.\"
.Dd January 14, 2005
.Dt ASIN 3
.Os
.Sh NAME
.Nm asin ,
.Nm asinf
.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"
.Sh DESCRIPTION
The
.Fn asin
and the
.Fn asinf
functions compute the principal value of the arc sine of
.Fa x .
A domain error occurs for arguments not in the range
.Bq -1 , +1 .
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
The
.Fn asin
and the
.Fn asinf
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
function conforms to
.St -isoC .

View File

@ -1,78 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.10 2001/10/13 12:23:22 bde 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 .

View File

@ -1,84 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.10 2001/10/13 12:23:22 bde Exp $
.\"
.Dd May 2, 1991
.Dt ATAN 3
.Os
.Sh NAME
.Nm atan ,
.Nm atanf
.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"
.Sh DESCRIPTION
The
.Fn atan
and the
.Fn atanf
functions compute the principal value of the arc tangent of
.Fa x .
For a discussion of error due to roundoff, see
.Xr math 3 .
.Sh RETURN VALUES
The
.Fn atan
and the
.Fn atanf
function returns 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
function conforms to
.St -isoC .

View File

@ -1,187 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.14 2005/01/28 21:13:34 ru Exp $
.\"
.Dd January 14, 2005
.Dt ATAN2 3
.Os
.Sh NAME
.Nm atan2 ,
.Nm atan2f
.Nd arc tangent functions of two variables
.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"
.Sh DESCRIPTION
The
.Fn atan2
and the
.Fn atan2f
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.
.Sh RETURN VALUES
The
.Fn atan2
and the
.Fn atan2f
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 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
function conforms to
.St -isoC .

View File

@ -1,85 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.13 2005/01/28 21:14:16 ru 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 .

View File

@ -1,82 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.15 2005/01/13 20:33:42 stefanf 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 .

View File

@ -1,96 +0,0 @@
.\" 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.2 2005/01/13 10:43:01 ru Exp $
.\"
.Dd August 7, 2004
.Dt CIMAG 3
.Os
.Sh NAME
.Nm cimag , cimagf , cimagl ,
.Nm conj , conjf , conjl ,
.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
.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 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 creal
functions return the real part
.Fa a .
.Sh STANDARDS
The
.Fn cimag ,
.Fn conj
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 .

View File

@ -1,90 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.1 2005/01/27 05:46:16 das 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.

View File

@ -1,83 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.11 2001/10/13 12:23:23 bde Exp $
.\"
.Dd May 2, 1991
.Dt COS 3
.Os
.Sh NAME
.Nm cos ,
.Nm cosf
.Nd cosine functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn cos "double x"
.Ft float
.Fn cosf "float x"
.Sh DESCRIPTION
The
.Fn cos
and the
.Fn cosf
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
and the
.Fn cosf
functions return the cosine value.
.Sh SEE ALSO
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
.Xr cosh 3 ,
.Xr math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Sh STANDARDS
The
.Fn cos
function conforms to
.St -isoC .

View File

@ -1,72 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.12 2005/01/14 23:28:28 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 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 .

View File

@ -1,97 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.11 2004/07/02 23:52:20 ru 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 .

View File

@ -1,236 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.22 2005/04/05 02:57:28 das Exp $
.\"
.Dd April 5, 2005
.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 expm1 ,
.Nm expm1f ,
.Nm log ,
.Nm logf ,
.Nm log10 ,
.Nm log10f ,
.Nm log1p ,
.Nm log1pf ,
.Nm pow ,
.Nm powf
.Nd exponential, logarithm, 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 double
.Fn expm1 "double x"
.Ft float
.Fn expm1f "float x"
.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 log1p "double x"
.Ft float
.Fn log1pf "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
and the
.Fn exp2f
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 log
and the
.Fn logf
functions compute the value of the natural logarithm of argument
.Fa x .
.Pp
The
.Fn log10
and the
.Fn log10f
functions compute the value of the logarithm of argument
.Fa x
to base 10.
.Pp
The
.Fn log1p
and the
.Fn log1pf
functions compute
the value of log(1+x) 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.
An attempt to take the logarithm of \*(Pm0 will result in
a divide-by-zero exception, and an infinity will be returned.
An attempt to take the logarithm of a negative number will
result in an invalid exception, and an \*(Na will be generated.
.Sh NOTES
The functions exp(x)\-1 and log(1+x) are called
expm1 and logp1 in
.Tn BASIC
on the Hewlett\-Packard
.Tn HP Ns \-71B
and
.Tn APPLE
Macintosh,
.Tn EXP1
and
.Tn LN1
in Pascal, exp1 and log1 in C
on
.Tn APPLE
Macintoshes, where they have been provided to make
sure financial calculations of ((1+x)**n\-1)/x, namely
expm1(n\(**log1p(x))/x, will be accurate when x is tiny.
They also provide accurate inverse hyperbolic functions.
.Pp
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 math 3

View File

@ -1,87 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.11 2004/07/01 18:20:57 ru 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 .

View File

@ -1,86 +0,0 @@
.\" 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.1 2004/06/30 07:04:01 das 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 iff 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 .

View File

@ -1,139 +0,0 @@
.\" 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 .

View File

@ -1,98 +0,0 @@
.\" 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.

View File

@ -1,113 +0,0 @@
.\" 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 .

View File

@ -1,83 +0,0 @@
.\" 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.

View File

@ -1,289 +0,0 @@
.\" 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.5 2005/06/15 19:04:04 ru 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 program attempts to
divide a finite non-zero number by zero.
.It Dv FE_INEXACT
An inexact exception is raised whenever there is a loss of precision
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 infinities, division of zero by zero,
ordered comparison involving \*(Nas, and taking the square root of a
negative number are all invalid operations.
.It Dv FE_OVERFLOW
An overflow exception occurs when the magnitude of the result of a
computation is too large to fit in the destination type.
.It Dv FE_UNDERFLOW
Underflow occurs when the result of a computation is too close to zero
to be represented as a non-zero value in the destination type.
.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
non-standard mechanisms.
.\" XXX Mention fe[gs]etmask() here after the interface is finalized
.\" XXX and ready to be officially documented.
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 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 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 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.
.Pp
On the Alpha platform,
.Xr cc 1
must be passed the
.Fl mieee-with-inexact mfp-rounding-mode=d
options in order to generate code that has the standard
side-effects and uses the specified rounding modes.

View File

@ -1,82 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.17 2005/01/13 09:35:47 ru 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 .

View File

@ -1,116 +0,0 @@
.\" 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 .

View File

@ -1,97 +0,0 @@
.\" 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 .

View File

@ -1,87 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.8 2001/10/13 12:23:23 bde Exp $
.\"
.Dd May 2, 1991
.Dt FMOD 3
.Os
.Sh NAME
.Nm fmod ,
.Nm fmodf
.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"
.Sh DESCRIPTION
The
.Fn fmod
and the
.Fn fmodf
functions compute the floating-point remainder of
.Fa x Ns / Fa y .
.Sh RETURN VALUES
The
.Fn fmod
and the
.Fn fmodf
functions return the value
.Sm off
.Fa x - Em i * Fa y ,
.Sm on
for some integer
.Em i
such that, if
.Fa y
is non-zero, the result has the same sign as
.Fa x
and magnitude less than the magnitude of
.Fa y .
If
.Fa y
is zero, whether a domain error occurs or the
.Fn fmod
and the
.Fn fmodf
function returns zero is implementation-defined.
.Sh SEE ALSO
.Xr math 3
.Sh STANDARDS
The
.Fn fmod
function conforms to
.St -isoC .

View File

@ -1,134 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.13 2005/01/14 23:28:28 das Exp $
.\"
.Dd January 14, 2005
.Dt HYPOT 3
.Os
.Sh NAME
.Nm hypot ,
.Nm hypotf ,
.Nm cabs ,
.Nm cabsf
.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"
.In complex.h
.Ft double
.Fn cabs "double complex z"
.Ft float
.Fn cabsf "float complex z"
.Sh DESCRIPTION
The
.Fn hypot
and
.Fn hypotf
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
and
.Fn cabsf
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.
.Pp
The same cannot be said for the shorter and faster version of hypot
and cabs that is provided in the comments in cabs.c; its error can
exceed 1.2
.Em ulps .
.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 math 3 ,
.Xr sqrt 3
.Sh HISTORY
Both a
.Fn hypot
function and a
.Fn cabs
function
appeared in
.At v7 .

View File

@ -1,448 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.22 2005/06/16 21:55:45 ru 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 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 double-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 double-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

View File

@ -1,93 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.13 2005/11/17 13:00:00 ru 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

View File

@ -1,127 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.3 2005/11/17 13:00:00 ru Exp $
.\"
.Dd November 6, 2005
.Dt ILOGB 3
.Os
.Sh NAME
.Nm ilogb ,
.Nm ilogbf ,
.Nm ilogbl ,
.Nm logb ,
.Nm logbf
.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"
.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
and
.Fn logbf 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
and
.Fn logbf
routines conform to
.St -isoC-99 .
.Fn logb
and
.Fn logbf
implement the logb function recommended by
.St -ieee754 .
.Sh HISTORY
The
.Fn logb
function appeared in
.Bx 4.3 .
The
.Fn ilogb
function appeared in
.Fx 1.1.5 .
The
.Fn ilogbf
and
.Fn logbf
functions appeared in
.Fx 2.0 .
The
.Fn ilogbl
function appeared in
.Fx 5.4 .

View File

@ -1,142 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.13 2005/01/14 23:28:28 das Exp $
.\"
.Dd January 14, 2005
.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
If these functions are successful,
the computed value is returned.
.Sh SEE ALSO
.Xr math 3
.Sh HISTORY
This set of functions
appeared in
.At v7 .

View File

@ -1,185 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.22 2005/01/16 16:46:14 ru 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
.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"
.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)|.
.Pp
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
.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.
.Fn tgamma x
returns \(*G(x), with no effect on
.Fa signgam .
.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
and
.Fn tgamma
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 .

View File

@ -1,94 +0,0 @@
.\" 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.2 2005/01/13 10:43:01 ru Exp $
.\"
.Dd January 11, 2005
.Dt LRINT 3
.Os
.Sh NAME
.Nm llrint ,
.Nm llrintf ,
.Nm lrint ,
.Nm lrintf
.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
.Fn lrint "double x"
.Ft long
.Fn lrintf "float 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 ,
and
.Fn lrintf
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
The
.Fn llrint ,
.Fn llrintf ,
.Fn lrint ,
and
.Fn lrintf
functions conform to
.St -isoC-99 .
.Sh HISTORY
These routines first appeared in
.Fx 5.4 .

View File

@ -1,112 +0,0 @@
.\" 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 .

View File

@ -1,242 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.27 2005/11/17 13:00:00 ru Exp $
.\"
.Dd November 6, 2005
.Dt MATH 3
.Os
.if n \{\
.char \[sr] "sqrt
.\}
.Sh NAME
.Nm math
.Nd "floating-point mathematical library"
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Sh DESCRIPTION
These functions constitute the C math library.
.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.
.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 Functions
.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
.\" .Cl
.\" nan return quiet \*(Na) 0
.\" .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
Unlike the algebraic functions listed earlier, the routines
in this section may 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 fenv 3 ,
.Xr ieee 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
The
.Fn log2
and
.Fn nan
functions are missing, and many functions are not available in their
.Vt "long double"
variants.
.Pp
Many of the routines to compute transcendental functions produce
inaccurate results in other than the default rounding mode.
.Pp
On some architectures, trigonometric argument reduction is not
performed accurately, resulting in errors greater than 1
.Em ulp
for large arguments to
.Fn cos ,
.Fn sin ,
and
.Fn tan .

View File

@ -1,100 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.2 2005/03/07 05:00:29 das 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 .

View File

@ -1,146 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.4 2005/11/24 09:25:10 joel Exp $
.\"
.Dd March 24, 2005
.Dt REMAINDER 3
.Os
.Sh NAME
.Nm remainder ,
.Nm remainderf ,
.Nm remquo ,
.Nm remquof
.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 double
.Fn remquo "double x" "double y" "int *quo"
.Ft float
.Fn remquof "float x" "float y" "int *quo"
.Sh DESCRIPTION
.Fn remainder ,
.Fn remainderf ,
.Fn remquo ,
and
.Fn remquof
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
and
.Fn remquof
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 remquo ,
and
.Fn remquof
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 .

View File

@ -1,103 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.11 2005/01/11 23:12:17 das Exp $
.\"
.Dd July 5, 2004
.Dt RINT 3
.Os
.Sh NAME
.Nm nearbyint ,
.Nm nearbyintf ,
.Nm rint ,
.Nm rintf
.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 double
.Fn rint "double x"
.Ft float
.Fn rintf "float x"
.Sh DESCRIPTION
The
.Fn rint
and the
.Fn rintf
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
and
.Fn nearbyintf
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
The
.Fn nearbyint ,
.Fn nearbyintf ,
.Fn rint ,
and
.Fn rintf
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 .

View File

@ -1,80 +0,0 @@
.\" 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 .

View File

@ -1,95 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.3 2005/11/24 09:25:10 joel 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 .

View File

@ -1,57 +0,0 @@
.\" 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 .

View File

@ -1,82 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.9 2001/10/13 12:23:23 bde Exp $
.\"
.Dd April 19, 1991
.Dt SIN 3
.Os
.Sh NAME
.Nm sin ,
.Nm sinf
.Nd sine functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn sin "double x"
.Ft float
.Fn sinf "float x"
.Sh DESCRIPTION
The
.Fn sin
and the
.Fn sinf
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
and the
.Fn sinf
functions return the sine value.
.Sh SEE ALSO
.Xr acos 3 ,
.Xr asin 3 ,
.Xr atan 3 ,
.Xr atan2 3 ,
.Xr cos 3 ,
.Xr cosh 3 ,
.Xr math 3 ,
.Xr sinh 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Sh STANDARDS
The
.Fn sin
function conforms to
.St -isoC .

View File

@ -1,71 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.12 2005/01/14 23:28:28 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 math 3 ,
.Xr sin 3 ,
.Xr tan 3 ,
.Xr tanh 3
.Sh STANDARDS
The
.Fn sinh
function conforms to
.St -isoC .

View File

@ -1,100 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.12 2005/01/14 23:28:28 das Exp $
.\"
.Dd May 6, 1991
.Dt SQRT 3
.Os
.Sh NAME
.Nm cbrt ,
.Nm cbrtf ,
.Nm sqrt ,
.Nm sqrtf
.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 double
.Fn sqrt "double x"
.Ft float
.Fn sqrtf "float x"
.Sh DESCRIPTION
The
.Fn cbrt
and the
.Fn cbrtf
functions compute
the cube root of
.Ar x .
.Pp
The
.Fn sqrt
and the
.Fn sqrtf
functions compute the
non-negative square root of x.
.Sh RETURN VALUES
The
.Fn cbrt
and the
.Fn cbrtf
functions return the requested cube root.
The
.Fn sqrt
and the
.Fn sqrtf
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.
.Sh SEE ALSO
.Xr fenv 3 ,
.Xr math 3
.Sh STANDARDS
The
.Fn sqrt
function conforms to
.St -isoC .
.Sh HISTORY
The
.Fn cbrt
function appeared in
.Bx 4.3 .

View File

@ -1,81 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.9 2001/10/13 12:23:23 bde Exp $
.\"
.Dd May 2, 1991
.Dt TAN 3
.Os
.Sh NAME
.Nm tan ,
.Nm tanf
.Nd tangent functions
.Sh LIBRARY
.Lb libm
.Sh SYNOPSIS
.In math.h
.Ft double
.Fn tan "double x"
.Ft float
.Fn tanf "float x"
.Sh DESCRIPTION
The
.Fn tan
and the
.Fn tanf
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
function returns 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 math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tanh 3
.Sh STANDARDS
The
.Fn tan
function conforms to
.St -isoC .

View File

@ -1,80 +0,0 @@
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.10 2001/10/13 12:23:23 bde 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 math 3 ,
.Xr sin 3 ,
.Xr sinh 3 ,
.Xr tan 3
.Sh STANDARDS
The
.Fn tanh
function conforms to
.St -isoC .

View File

@ -1,80 +0,0 @@
.\" 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 .

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/libc/mips/_fpmath.h,v 1.1 2008/04/26 12:07:59 imp Exp $
* $FreeBSD$
*/
union IEEEl2bits {

View File

@ -1,84 +0,0 @@
/* e_asinf.c -- float version of e_asin.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* 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.
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_asinf.c,v 1.9 2005/12/04 13:52:46 bde Exp $";
#endif
#include "math.h"
#include "math_private.h"
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
huge = 1.000e+30,
pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */
pio2_lo = 7.5497894159e-08, /* 0x33a22168 */
pio4_hi = 7.8539812565e-01, /* 0x3f490fda */
/* coefficient for R(x^2) */
pS0 = 1.6666667163e-01, /* 0x3e2aaaab */
pS1 = -3.2556581497e-01, /* 0xbea6b090 */
pS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */
pS3 = -4.0055535734e-02, /* 0xbd241146 */
pS4 = 7.9153501429e-04, /* 0x3a4f7f04 */
pS5 = 3.4793309169e-05, /* 0x3811ef08 */
qS1 = -2.4033949375e+00, /* 0xc019d139 */
qS2 = 2.0209457874e+00, /* 0x4001572d */
qS3 = -6.8828397989e-01, /* 0xbf303361 */
qS4 = 7.7038154006e-02; /* 0x3d9dc62e */
float
__ieee754_asinf(float x)
{
float t=0.0,w,p,q,c,r,s;
int32_t hx,ix;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if(ix==0x3f800000) {
/* asin(1)=+-pi/2 with inexact */
return x*pio2_hi+x*pio2_lo;
} else if(ix> 0x3f800000) { /* |x|>= 1 */
return (x-x)/(x-x); /* asin(|x|>1) is NaN */
} else if (ix<0x3f000000) { /* |x|<0.5 */
if(ix<0x32000000) { /* if |x| < 2**-27 */
if(huge+x>one) return x;/* return x with inexact if x!=0*/
} else
t = x*x;
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
w = p/q;
return x+x*w;
}
/* 1> |x|>= 0.5 */
w = one-fabsf(x);
t = w*(float)0.5;
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
s = __ieee754_sqrtf(t);
if(ix>=0x3F79999A) { /* if |x| > 0.975 */
w = p/q;
t = pio2_hi-((float)2.0*(s+s*w)-pio2_lo);
} else {
int32_t iw;
w = s;
GET_FLOAT_WORD(iw,w);
SET_FLOAT_WORD(w,iw&0xfffff000);
c = (t-w*w)/(s+w);
r = p/q;
p = (float)2.0*s*r-(pio2_lo-(float)2.0*c);
q = pio4_hi-(float)2.0*w;
t = pio4_hi-(p-q);
}
if(hx>0) return t; else return -t;
}

View File

@ -1,22 +0,0 @@
/* e_scalbf.c -- float version of e_scalb.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* 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.
* ====================================================
*/
#include "math.h"
#include "math_private.h"
float
__ieee754_ldexpf(float x, int fn)
{
return __ieee754_scalbf(x,fn);
}

View File

@ -1,87 +0,0 @@
/* @(#)e_log10.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* 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.
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_log10.c,v 1.11 2005/02/04 18:26:06 das Exp $";
#endif
/* __ieee754_log10(x)
* Return the base 10 logarithm of x
*
* Method :
* Let log10_2hi = leading 40 bits of log10(2) and
* log10_2lo = log10(2) - log10_2hi,
* ivln10 = 1/log(10) rounded.
* Then
* n = ilogb(x),
* if(n<0) n = n+1;
* x = scalbn(x,-n);
* log10(x) := n*log10_2hi + (n*log10_2lo + ivln10*log(x))
*
* Note 1:
* To guarantee log10(10**n)=n, where 10**n is normal, the rounding
* mode must set to Round-to-Nearest.
* Note 2:
* [1/log(10)] rounded to 53 bits has error .198 ulps;
* log10 is monotonic at all binary break points.
*
* Special cases:
* log10(x) is NaN with signal if x < 0;
* log10(+INF) is +INF with no signal; log10(0) is -INF with signal;
* log10(NaN) is that NaN with no signal;
* log10(10**N) = N for N=0,1,...,22.
*
* Constants:
* The hexadecimal values are the intended ones for the following constants.
* The decimal values may be used, provided that the compiler will convert
* from decimal to binary accurately enough to produce the hexadecimal values
* shown.
*/
#include "math.h"
#include "math_private.h"
static const double
two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
ivln10 = 4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */
log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */
log10_2lo = 3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */
static const double zero = 0.0;
double
__ieee754_log10(double x)
{
double y,z;
int32_t i,k,hx;
u_int32_t lx;
EXTRACT_WORDS(hx,lx,x);
k=0;
if (hx < 0x00100000) { /* x < 2**-1022 */
if (((hx&0x7fffffff)|lx)==0)
return -two54/zero; /* log(+-0)=-inf */
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 54; x *= two54; /* subnormal number, scale up x */
GET_HIGH_WORD(hx,x);
}
if (hx >= 0x7ff00000) return x+x;
k += (hx>>20)-1023;
i = ((u_int32_t)k&0x80000000)>>31;
hx = (hx&0x000fffff)|((0x3ff-i)<<20);
y = (double)(k+i);
SET_HIGH_WORD(x,hx);
z = y*log10_2lo + ivln10*__ieee754_log(x);
return z+y*log10_2hi;
}

View File

@ -1,55 +0,0 @@
/* e_log10f.c -- float version of e_log10.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* 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.
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_log10f.c,v 1.8 2002/05/28 18:15:04 alfred Exp $";
#endif
#include "math.h"
#include "math_private.h"
static const float
two25 = 3.3554432000e+07, /* 0x4c000000 */
ivln10 = 4.3429449201e-01, /* 0x3ede5bd9 */
log10_2hi = 3.0102920532e-01, /* 0x3e9a2080 */
log10_2lo = 7.9034151668e-07; /* 0x355427db */
static const float zero = 0.0;
float
__ieee754_log10f(float x)
{
float y,z;
int32_t i,k,hx;
GET_FLOAT_WORD(hx,x);
k=0;
if (hx < 0x00800000) { /* x < 2**-126 */
if ((hx&0x7fffffff)==0)
return -two25/zero; /* log(+-0)=-inf */
if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
k -= 25; x *= two25; /* subnormal number, scale up x */
GET_FLOAT_WORD(hx,x);
}
if (hx >= 0x7f800000) return x+x;
k += (hx>>23)-127;
i = ((u_int32_t)k&0x80000000)>>31;
hx = (hx&0x007fffff)|((0x7f-i)<<23);
y = (float)(k+i);
SET_FLOAT_WORD(x,hx);
z = y*log10_2lo + ivln10*__ieee754_logf(x);
return z+y*log10_2hi;
}

View File

@ -1,98 +0,0 @@
/* e_rem_pio2f.c -- float version of e_rem_pio2.c
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Debugged and optimized by Bruce D. Evans.
*/
/*
* ====================================================
* 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.
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_rem_pio2f.c,v 1.19 2005/11/23 03:03:09 bde Exp $";
#endif
/* __ieee754_rem_pio2f(x,y)
*
* return the remainder of x rem pi/2 in y[0]+y[1]
* use double precision internally
* use __kernel_rem_pio2() for large x
*/
#include "math.h"
#include "math_private.h"
/*
* Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
*/
static const int32_t two_over_pi[] = {
0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62,
0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A,
0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129,
0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41,
0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8,
0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF,
0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5,
0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08,
0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3,
0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880,
0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B,
};
/*
* invpio2: 53 bits of 2/pi
* pio2_1: first 33 bit of pi/2
* pio2_1t: pi/2 - pio2_1
*/
static const double
zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */
pio2_1t = 6.07710050650619224932e-11; /* 0x3DD0B461, 0x1A626331 */
int32_t __ieee754_rem_pio2f(float x, float *y)
{
double w,t,r,fn;
double tx[1],ty[2];
float z;
int32_t e0,n,ix,hx;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
/* 33+53 bit pi is good enough for medium size */
if(ix<=0x49490f80) { /* |x| ~<= 2^19*(pi/2), medium size */
t = fabsf(x);
n = (int32_t) (t*invpio2+half);
fn = (double)n;
r = t-fn*pio2_1;
w = fn*pio2_1t;
y[0] = r-w;
y[1] = (r-y[0])-w;
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
else return n;
}
/*
* all other (large) arguments
*/
if(ix>=0x7f800000) { /* x is inf or NaN */
y[0]=y[1]=x-x; return 0;
}
/* set z = scalbn(|x|,ilogb(|x|)-23) */
e0 = (ix>>23)-150; /* e0 = ilogb(|x|)-23; */
SET_FLOAT_WORD(z, ix - ((int32_t)(e0<<23)));
tx[0] = z;
n = __kernel_rem_pio2(tx,ty,e0,1,1,two_over_pi);
y[0] = ty[0];
y[1] = ty[0] - y[0];
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
return n;
}

View File

@ -1,304 +0,0 @@
/* @(#)k_rem_pio2.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* 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.
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/k_rem_pio2.c,v 1.7 2005/02/04 18:26:06 das Exp $";
#endif
/*
* __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)
* double x[],y[]; int e0,nx,prec; int ipio2[];
*
* __kernel_rem_pio2 return the last three digits of N with
* y = x - N*pi/2
* so that |y| < pi/2.
*
* The method is to compute the integer (mod 8) and fraction parts of
* (2/pi)*x without doing the full multiplication. In general we
* skip the part of the product that are known to be a huge integer (
* more accurately, = 0 mod 8 ). Thus the number of operations are
* independent of the exponent of the input.
*
* (2/pi) is represented by an array of 24-bit integers in ipio2[].
*
* Input parameters:
* x[] The input value (must be positive) is broken into nx
* pieces of 24-bit integers in double precision format.
* x[i] will be the i-th 24 bit of x. The scaled exponent
* of x[0] is given in input parameter e0 (i.e., x[0]*2^e0
* match x's up to 24 bits.
*
* Example of breaking a double positive z into x[0]+x[1]+x[2]:
* e0 = ilogb(z)-23
* z = scalbn(z,-e0)
* for i = 0,1,2
* x[i] = floor(z)
* z = (z-x[i])*2**24
*
*
* y[] ouput result in an array of double precision numbers.
* The dimension of y[] is:
* 24-bit precision 1
* 53-bit precision 2
* 64-bit precision 2
* 113-bit precision 3
* The actual value is the sum of them. Thus for 113-bit
* precison, one may have to do something like:
*
* long double t,w,r_head, r_tail;
* t = (long double)y[2] + (long double)y[1];
* w = (long double)y[0];
* r_head = t+w;
* r_tail = w - (r_head - t);
*
* e0 The exponent of x[0]
*
* nx dimension of x[]
*
* prec an integer indicating the precision:
* 0 24 bits (single)
* 1 53 bits (double)
* 2 64 bits (extended)
* 3 113 bits (quad)
*
* ipio2[]
* integer array, contains the (24*i)-th to (24*i+23)-th
* bit of 2/pi after binary point. The corresponding
* floating value is
*
* ipio2[i] * 2^(-24(i+1)).
*
* External function:
* double scalbn(), floor();
*
*
* Here is the description of some local variables:
*
* jk jk+1 is the initial number of terms of ipio2[] needed
* in the computation. The recommended value is 2,3,4,
* 6 for single, double, extended,and quad.
*
* jz local integer variable indicating the number of
* terms of ipio2[] used.
*
* jx nx - 1
*
* jv index for pointing to the suitable ipio2[] for the
* computation. In general, we want
* ( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8
* is an integer. Thus
* e0-3-24*jv >= 0 or (e0-3)/24 >= jv
* Hence jv = max(0,(e0-3)/24).
*
* jp jp+1 is the number of terms in PIo2[] needed, jp = jk.
*
* q[] double array with integral value, representing the
* 24-bits chunk of the product of x and 2/pi.
*
* q0 the corresponding exponent of q[0]. Note that the
* exponent for q[i] would be q0-24*i.
*
* PIo2[] double precision array, obtained by cutting pi/2
* into 24 bits chunks.
*
* f[] ipio2[] in floating point
*
* iq[] integer array by breaking up q[] in 24-bits chunk.
*
* fq[] final product of x*(2/pi) in fq[0],..,fq[jk]
*
* ih integer. If >0 it indicates q[] is >= 0.5, hence
* it also indicates the *sign* of the result.
*
*/
/*
* Constants:
* The hexadecimal values are the intended ones for the following
* constants. The decimal values may be used, provided that the
* compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
#include "math.h"
#include "math_private.h"
static const int init_jk[] = {2,3,4,6}; /* initial value for jk */
static const double PIo2[] = {
1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */
7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */
5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */
3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */
1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */
1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */
2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */
2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */
};
static const double
zero = 0.0,
one = 1.0,
two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2)
{
int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
double z,fw,f[20],fq[20],q[20];
/* initialize jk*/
jk = init_jk[prec];
jp = jk;
/* determine jx,jv,q0, note that 3>q0 */
jx = nx-1;
jv = (e0-3)/24; if(jv<0) jv=0;
q0 = e0-24*(jv+1);
/* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
j = jv-jx; m = jx+jk;
for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j];
/* compute q[0],q[1],...q[jk] */
for (i=0;i<=jk;i++) {
for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
}
jz = jk;
recompute:
/* distill q[] into iq[] reversingly */
for(i=0,j=jz,z=q[jz];j>0;i++,j--) {
fw = (double)((int32_t)(twon24* z));
iq[i] = (int32_t)(z-two24*fw);
z = q[j-1]+fw;
}
/* compute n */
z = scalbn(z,q0); /* actual value of z */
z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */
n = (int32_t) z;
z -= (double)n;
ih = 0;
if(q0>0) { /* need iq[jz-1] to determine n */
i = (iq[jz-1]>>(24-q0)); n += i;
iq[jz-1] -= i<<(24-q0);
ih = iq[jz-1]>>(23-q0);
}
else if(q0==0) ih = iq[jz-1]>>23;
else if(z>=0.5) ih=2;
if(ih>0) { /* q > 0.5 */
n += 1; carry = 0;
for(i=0;i<jz ;i++) { /* compute 1-q */
j = iq[i];
if(carry==0) {
if(j!=0) {
carry = 1; iq[i] = 0x1000000- j;
}
} else iq[i] = 0xffffff - j;
}
if(q0>0) { /* rare case: chance is 1 in 12 */
switch(q0) {
case 1:
iq[jz-1] &= 0x7fffff; break;
case 2:
iq[jz-1] &= 0x3fffff; break;
}
}
if(ih==2) {
z = one - z;
if(carry!=0) z -= scalbn(one,q0);
}
}
/* check if recomputation is needed */
if(z==zero) {
j = 0;
for (i=jz-1;i>=jk;i--) j |= iq[i];
if(j==0) { /* need recomputation */
for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */
for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */
f[jx+i] = (double) ipio2[jv+i];
for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
q[i] = fw;
}
jz += k;
goto recompute;
}
}
/* chop off zero terms */
if(z==0.0) {
jz -= 1; q0 -= 24;
while(iq[jz]==0) { jz--; q0-=24;}
} else { /* break z into 24-bit if necessary */
z = scalbn(z,-q0);
if(z>=two24) {
fw = (double)((int32_t)(twon24*z));
iq[jz] = (int32_t)(z-two24*fw);
jz += 1; q0 += 24;
iq[jz] = (int32_t) fw;
} else iq[jz] = (int32_t) z ;
}
/* convert integer "bit" chunk to floating-point value */
fw = scalbn(one,q0);
for(i=jz;i>=0;i--) {
q[i] = fw*(double)iq[i]; fw*=twon24;
}
/* compute PIo2[0,...,jp]*q[jz,...,0] */
for(i=jz;i>=0;i--) {
for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k];
fq[jz-i] = fw;
}
/* compress fq[] into y[] */
switch(prec) {
case 0:
fw = 0.0;
for (i=jz;i>=0;i--) fw += fq[i];
y[0] = (ih==0)? fw: -fw;
break;
case 1:
case 2:
fw = 0.0;
for (i=jz;i>=0;i--) fw += fq[i];
y[0] = (ih==0)? fw: -fw;
fw = fq[0]-fw;
for (i=1;i<=jz;i++) fw += fq[i];
y[1] = (ih==0)? fw: -fw;
break;
case 3: /* painful */
for (i=jz;i>0;i--) {
fw = fq[i-1]+fq[i];
fq[i] += fq[i-1]-fw;
fq[i-1] = fw;
}
for (i=jz;i>1;i--) {
fw = fq[i-1]+fq[i];
fq[i] += fq[i-1]-fw;
fq[i-1] = fw;
}
for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
if(ih==0) {
y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
} else {
y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;
}
}
return n&7;
}

View File

@ -1,197 +0,0 @@
/* k_rem_pio2f.c -- float version of k_rem_pio2.c
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* 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.
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/k_rem_pio2f.c,v 1.8 2005/10/11 07:56:05 bde Exp $";
#endif
#include "math.h"
#include "math_private.h"
/* In the float version, the input parameter x contains 8 bit
integers, not 24 bit integers. 113 bit precision is not supported. */
static const int init_jk[] = {4,7,9}; /* initial value for jk */
static const float PIo2[] = {
1.5703125000e+00, /* 0x3fc90000 */
4.5776367188e-04, /* 0x39f00000 */
2.5987625122e-05, /* 0x37da0000 */
7.5437128544e-08, /* 0x33a20000 */
6.0026650317e-11, /* 0x2e840000 */
7.3896444519e-13, /* 0x2b500000 */
5.3845816694e-15, /* 0x27c20000 */
5.6378512969e-18, /* 0x22d00000 */
8.3009228831e-20, /* 0x1fc40000 */
3.2756352257e-22, /* 0x1bc60000 */
6.3331015649e-25, /* 0x17440000 */
};
static const float
zero = 0.0,
one = 1.0,
two8 = 2.5600000000e+02, /* 0x43800000 */
twon8 = 3.9062500000e-03; /* 0x3b800000 */
int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const int32_t *ipio2)
{
int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
float z,fw,f[20],fq[20],q[20];
/* initialize jk*/
jk = init_jk[prec];
jp = jk;
/* determine jx,jv,q0, note that 3>q0 */
jx = nx-1;
jv = (e0-3)/8; if(jv<0) jv=0;
q0 = e0-8*(jv+1);
/* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
j = jv-jx; m = jx+jk;
for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (float) ipio2[j];
/* compute q[0],q[1],...q[jk] */
for (i=0;i<=jk;i++) {
for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
}
jz = jk;
recompute:
/* distill q[] into iq[] reversingly */
for(i=0,j=jz,z=q[jz];j>0;i++,j--) {
fw = (float)((int32_t)(twon8* z));
iq[i] = (int32_t)(z-two8*fw);
z = q[j-1]+fw;
}
/* compute n */
z = scalbnf(z,q0); /* actual value of z */
z -= (float)8.0*floorf(z*(float)0.125); /* trim off integer >= 8 */
n = (int32_t) z;
z -= (float)n;
ih = 0;
if(q0>0) { /* need iq[jz-1] to determine n */
i = (iq[jz-1]>>(8-q0)); n += i;
iq[jz-1] -= i<<(8-q0);
ih = iq[jz-1]>>(7-q0);
}
else if(q0==0) ih = iq[jz-1]>>7;
else if(z>=(float)0.5) ih=2;
if(ih>0) { /* q > 0.5 */
n += 1; carry = 0;
for(i=0;i<jz ;i++) { /* compute 1-q */
j = iq[i];
if(carry==0) {
if(j!=0) {
carry = 1; iq[i] = 0x100- j;
}
} else iq[i] = 0xff - j;
}
if(q0>0) { /* rare case: chance is 1 in 12 */
switch(q0) {
case 1:
iq[jz-1] &= 0x7f; break;
case 2:
iq[jz-1] &= 0x3f; break;
}
}
if(ih==2) {
z = one - z;
if(carry!=0) z -= scalbnf(one,q0);
}
}
/* check if recomputation is needed */
if(z==zero) {
j = 0;
for (i=jz-1;i>=jk;i--) j |= iq[i];
if(j==0) { /* need recomputation */
for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */
for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */
f[jx+i] = (float) ipio2[jv+i];
for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
q[i] = fw;
}
jz += k;
goto recompute;
}
}
/* chop off zero terms */
if(z==(float)0.0) {
jz -= 1; q0 -= 8;
while(iq[jz]==0) { jz--; q0-=8;}
} else { /* break z into 8-bit if necessary */
z = scalbnf(z,-q0);
if(z>=two8) {
fw = (float)((int32_t)(twon8*z));
iq[jz] = (int32_t)(z-two8*fw);
jz += 1; q0 += 8;
iq[jz] = (int32_t) fw;
} else iq[jz] = (int32_t) z ;
}
/* convert integer "bit" chunk to floating-point value */
fw = scalbnf(one,q0);
for(i=jz;i>=0;i--) {
q[i] = fw*(float)iq[i]; fw*=twon8;
}
/* compute PIo2[0,...,jp]*q[jz,...,0] */
for(i=jz;i>=0;i--) {
for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k];
fq[jz-i] = fw;
}
/* compress fq[] into y[] */
switch(prec) {
case 0:
fw = 0.0;
for (i=jz;i>=0;i--) fw += fq[i];
y[0] = (ih==0)? fw: -fw;
break;
case 1:
case 2:
fw = 0.0;
for (i=jz;i>=0;i--) fw += fq[i];
fw = *(volatile float *)&fw; /* clip any extra precision */
y[0] = (ih==0)? fw: -fw;
fw = fq[0]-fw;
for (i=1;i<=jz;i++) fw += fq[i];
y[1] = (ih==0)? fw: -fw;
break;
case 3: /* painful */
for (i=jz;i>0;i--) {
fw = fq[i-1]+fq[i];
fq[i] += fq[i-1]-fw;
fq[i-1] = fw;
}
for (i=jz;i>1;i--) {
fw = fq[i-1]+fq[i];
fq[i] += fq[i-1]-fw;
fq[i-1] = fw;
}
for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
if(ih==0) {
y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
} else {
y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;
}
}
return n&7;
}

View File

@ -1,92 +0,0 @@
/* @(#)s_cbrt.c 5.1 93/09/24 */
/*
* ====================================================
* 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.
* ====================================================
*
* Optimized by Bruce D. Evans.
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_cbrt.c,v 1.10 2005/12/13 20:17:23 bde Exp $";
#endif
#include "math.h"
#include "math_private.h"
/* cbrt(x)
* Return cube root of x
*/
static const u_int32_t
B1 = 715094163, /* B1 = (1023-1023/3-0.03306235651)*2**20 */
B2 = 696219795; /* B2 = (1023-1023/3-54/3-0.03306235651)*2**20 */
static const double
C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */
D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */
E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */
F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */
G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */
double
cbrt(double x)
{
int32_t hx;
double r,s,t=0.0,w;
u_int32_t sign;
u_int32_t high,low;
GET_HIGH_WORD(hx,x);
sign=hx&0x80000000; /* sign= sign(x) */
hx ^=sign;
if(hx>=0x7ff00000) return(x+x); /* cbrt(NaN,INF) is itself */
GET_LOW_WORD(low,x);
if((hx|low)==0)
return(x); /* cbrt(0) is itself */
/*
* Rough cbrt to 5 bits:
* cbrt(2**e*(1+m) ~= 2**(e/3)*(1+(e%3+m)/3)
* where e is integral and >= 0, m is real and in [0, 1), and "/" and
* "%" are integer division and modulus with rounding towards minus
* infinity. The RHS is always >= the LHS and has a maximum relative
* error of about 1 in 16. Adding a bias of -0.03306235651 to the
* (e%3+m)/3 term reduces the error to about 1 in 32. With the IEEE
* floating point representation, for finite positive normal values,
* ordinary integer divison of the value in bits magically gives
* almost exactly the RHS of the above provided we first subtract the
* exponent bias (1023 for doubles) and later add it back. We do the
* subtraction virtually to keep e >= 0 so that ordinary integer
* division rounds towards minus infinity; this is also efficient.
*/
if(hx<0x00100000) { /* subnormal number */
SET_HIGH_WORD(t,0x43500000); /* set t= 2**54 */
t*=x;
GET_HIGH_WORD(high,t);
SET_HIGH_WORD(t,sign|((high&0x7fffffff)/3+B2));
} else
SET_HIGH_WORD(t,sign|(hx/3+B1));
/* new cbrt to 23 bits; may be implemented in single precision */
r=t*t/x;
s=C+r*t;
t*=G+F/(s+E+D/s);
/* chop t to 20 bits and make it larger in magnitude than cbrt(x) */
GET_HIGH_WORD(high,t);
INSERT_WORDS(t,high+0x00000001,0);
/* one step Newton iteration to 53 bits with error less than 0.667 ulps */
s=t*t; /* t*t is exact */
r=x/s;
w=t+t;
r=(r-t)/(w+r); /* r-t is exact */
t=t+t*r;
return(t);
}

View File

@ -1,202 +0,0 @@
/*-
* 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 <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fma.c,v 1.4 2005/03/18 02:27:59 das Exp $"); */
#include <fenv.h>
#include <float.h>
#include <math.h>
/*
* Fused multiply-add: Compute x * y + z with a single rounding error.
*
* We use scaling to avoid overflow/underflow, along with the
* canonical precision-doubling technique adapted from:
*
* Dekker, T. A Floating-Point Technique for Extending the
* Available Precision. Numer. Math. 18, 224-242 (1971).
*
* This algorithm is sensitive to the rounding precision. FPUs such
* as the i387 must be set in double-precision mode if variables are
* to be stored in FP registers in order to avoid incorrect results.
* This is the default on FreeBSD, but not on many other systems.
*
* Hardware instructions should be used on architectures that support it,
* since this implementation will likely be several times slower.
*/
#if LDBL_MANT_DIG != 113
double
fma(double x, double y, double z)
{
static const double split = 0x1p27 + 1.0;
double xs, ys, zs;
double c, cc, hx, hy, p, q, tx, ty;
double r, rr, s;
int oround;
int ex, ey, ez;
int spread;
if (z == 0.0)
return (x * y);
if (x == 0.0 || y == 0.0)
return (x * y + z);
/* Results of frexp() are undefined for these cases. */
if (!isfinite(x) || !isfinite(y) || !isfinite(z))
return (x * y + z);
xs = frexp(x, &ex);
ys = frexp(y, &ey);
zs = frexp(z, &ez);
oround = fegetround();
spread = ex + ey - ez;
/*
* If x * y and z are many orders of magnitude apart, the scaling
* will overflow, so we handle these cases specially. Rounding
* modes other than FE_TONEAREST are painful.
*/
if (spread > DBL_MANT_DIG * 2) {
fenv_t env;
feraiseexcept(FE_INEXACT);
switch(oround) {
case FE_TONEAREST:
return (x * y);
case FE_TOWARDZERO:
if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
return (x * y);
feholdexcept(&env);
r = x * y;
if (!fetestexcept(FE_INEXACT))
r = nextafter(r, 0);
feupdateenv(&env);
return (r);
case FE_DOWNWARD:
if (z > 0.0)
return (x * y);
feholdexcept(&env);
r = x * y;
if (!fetestexcept(FE_INEXACT))
r = nextafter(r, -INFINITY);
feupdateenv(&env);
return (r);
default: /* FE_UPWARD */
if (z < 0.0)
return (x * y);
feholdexcept(&env);
r = x * y;
if (!fetestexcept(FE_INEXACT))
r = nextafter(r, INFINITY);
feupdateenv(&env);
return (r);
}
}
if (spread < -DBL_MANT_DIG) {
feraiseexcept(FE_INEXACT);
if (!isnormal(z))
feraiseexcept(FE_UNDERFLOW);
switch (oround) {
case FE_TONEAREST:
return (z);
case FE_TOWARDZERO:
if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
return (z);
else
return (nextafter(z, 0));
case FE_DOWNWARD:
if (x > 0.0 ^ y < 0.0)
return (z);
else
return (nextafter(z, -INFINITY));
default: /* FE_UPWARD */
if (x > 0.0 ^ y < 0.0)
return (nextafter(z, INFINITY));
else
return (z);
}
}
/*
* Use Dekker's algorithm to perform the multiplication and
* subsequent addition in twice the machine precision.
* Arrange so that x * y = c + cc, and x * y + z = r + rr.
*/
fesetround(FE_TONEAREST);
p = xs * split;
hx = xs - p;
hx += p;
tx = xs - hx;
p = ys * split;
hy = ys - p;
hy += p;
ty = ys - hy;
p = hx * hy;
q = hx * ty + tx * hy;
c = p + q;
cc = p - c + q + tx * ty;
zs = ldexp(zs, -spread);
r = c + zs;
s = r - c;
rr = (c - (r - s)) + (zs - s) + cc;
spread = ex + ey;
if (spread + ilogb(r) > -1023) {
fesetround(oround);
r = r + rr;
} else {
/*
* The result is subnormal, so we round before scaling to
* avoid double rounding.
*/
p = ldexp(copysign(0x1p-1022, r), -spread);
c = r + p;
s = c - r;
cc = (r - (c - s)) + (p - s) + rr;
fesetround(oround);
r = (c + cc) - p;
}
return (ldexp(r, spread));
}
#else /* LDBL_MANT_DIG == 113 */
/*
* 113 bits of precision is more than twice the precision of a double,
* so it is enough to represent the intermediate product exactly.
*/
double
fma(double x, double y, double z)
{
return ((long double)x * y + z);
}
#endif /* LDBL_MANT_DIG != 113 */
#if (LDBL_MANT_DIG == 53)
__weak_reference(fma, fmal);
#endif

View File

@ -1,182 +0,0 @@
/*-
* 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 <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/lib/msun/src/s_fmal.c,v 1.2 2005/03/18 02:27:59 das Exp $"); */
#include <fenv.h>
#include <float.h>
#include <math.h>
/*
* Fused multiply-add: Compute x * y + z with a single rounding error.
*
* We use scaling to avoid overflow/underflow, along with the
* canonical precision-doubling technique adapted from:
*
* Dekker, T. A Floating-Point Technique for Extending the
* Available Precision. Numer. Math. 18, 224-242 (1971).
*/
long double
fmal(long double x, long double y, long double z)
{
#if LDBL_MANT_DIG == 64
static const long double split = 0x1p32L + 1.0;
#elif LDBL_MANT_DIG == 113
static const long double split = 0x1p57L + 1.0;
#endif
long double xs, ys, zs;
long double c, cc, hx, hy, p, q, tx, ty;
long double r, rr, s;
int oround;
int ex, ey, ez;
int spread;
if (z == 0.0)
return (x * y);
if (x == 0.0 || y == 0.0)
return (x * y + z);
/* Results of frexp() are undefined for these cases. */
if (!isfinite(x) || !isfinite(y) || !isfinite(z))
return (x * y + z);
xs = frexpl(x, &ex);
ys = frexpl(y, &ey);
zs = frexpl(z, &ez);
oround = fegetround();
spread = ex + ey - ez;
/*
* If x * y and z are many orders of magnitude apart, the scaling
* will overflow, so we handle these cases specially. Rounding
* modes other than FE_TONEAREST are painful.
*/
if (spread > LDBL_MANT_DIG * 2) {
fenv_t env;
feraiseexcept(FE_INEXACT);
switch(oround) {
case FE_TONEAREST:
return (x * y);
case FE_TOWARDZERO:
if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
return (x * y);
feholdexcept(&env);
r = x * y;
if (!fetestexcept(FE_INEXACT))
r = nextafterl(r, 0);
feupdateenv(&env);
return (r);
case FE_DOWNWARD:
if (z > 0.0)
return (x * y);
feholdexcept(&env);
r = x * y;
if (!fetestexcept(FE_INEXACT))
r = nextafterl(r, -INFINITY);
feupdateenv(&env);
return (r);
default: /* FE_UPWARD */
if (z < 0.0)
return (x * y);
feholdexcept(&env);
r = x * y;
if (!fetestexcept(FE_INEXACT))
r = nextafterl(r, INFINITY);
feupdateenv(&env);
return (r);
}
}
if (spread < -LDBL_MANT_DIG) {
feraiseexcept(FE_INEXACT);
if (!isnormal(z))
feraiseexcept(FE_UNDERFLOW);
switch (oround) {
case FE_TONEAREST:
return (z);
case FE_TOWARDZERO:
if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
return (z);
else
return (nextafterl(z, 0));
case FE_DOWNWARD:
if (x > 0.0 ^ y < 0.0)
return (z);
else
return (nextafterl(z, -INFINITY));
default: /* FE_UPWARD */
if (x > 0.0 ^ y < 0.0)
return (nextafterl(z, INFINITY));
else
return (z);
}
}
/*
* Use Dekker's algorithm to perform the multiplication and
* subsequent addition in twice the machine precision.
* Arrange so that x * y = c + cc, and x * y + z = r + rr.
*/
fesetround(FE_TONEAREST);
p = xs * split;
hx = xs - p;
hx += p;
tx = xs - hx;
p = ys * split;
hy = ys - p;
hy += p;
ty = ys - hy;
p = hx * hy;
q = hx * ty + tx * hy;
c = p + q;
cc = p - c + q + tx * ty;
zs = ldexpl(zs, -spread);
r = c + zs;
s = r - c;
rr = (c - (r - s)) + (zs - s) + cc;
spread = ex + ey;
if (spread + ilogbl(r) > -16383) {
fesetround(oround);
r = r + rr;
} else {
/*
* The result is subnormal, so we round before scaling to
* avoid double rounding.
*/
p = ldexpl(copysignl(0x1p-16382L, r), -spread);
c = r + p;
s = c - r;
cc = (r - (c - s)) + (p - s) + rr;
fesetround(oround);
r = (c + cc) - p;
}
return (ldexpl(r, spread));
}

View File

@ -1,11 +0,0 @@
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/lib/msun/src/s_llround.c,v 1.2 2005/04/08 00:52:27 das Exp $"); */
#define type double
#define roundit round
#define dtype long long
#define DTYPE_MIN LONGLONG_MIN
#define DTYPE_MAX LONGLONG_MAX
#define fn llround
#include "s_lround.c"

View File

@ -1,11 +0,0 @@
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/lib/msun/src/s_llroundf.c,v 1.2 2005/04/08 00:52:27 das Exp $"); */
#define type float
#define roundit roundf
#define dtype long long
#define DTYPE_MIN LONGLONG_MIN
#define DTYPE_MAX LONGLONG_MAX
#define fn llroundf
#include "s_lround.c"

View File

@ -1,11 +0,0 @@
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/lib/msun/src/s_llroundl.c,v 1.1 2005/04/08 01:24:08 das Exp $"); */
#define type long double
#define roundit roundl
#define dtype long long
#define DTYPE_MIN LONGLONG_MIN
#define DTYPE_MAX LONGLONG_MAX
#define fn llroundl
#include "s_lround.c"

View File

@ -1,28 +0,0 @@
/*
* cabs() wrapper for hypot().
*
* Written by J.T. Conklin, <jtc@wimsey.com>
* Placed into the Public Domain, 1994.
*/
#ifndef lint
static const char rcsid[] =
"$FreeBSD: src/lib/msun/src/w_cabs.c,v 1.4 2001/06/13 15:16:30 ru Exp $";
#endif /* not lint */
#include <complex.h>
#include <math.h>
double
cabs(z)
double complex z;
{
return hypot(creal(z), cimag(z));
}
double
z_abs(z)
double complex *z;
{
return hypot(creal(*z), cimag(*z));
}

View File

@ -31,11 +31,9 @@
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)exp.c 8.1 (Berkeley) 6/4/93";
#endif /* not lint */
/* @(#)exp.c 8.1 (Berkeley) 6/4/93 */
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_exp.c,v 1.7 2004/12/16 20:40:37 das Exp $"); */
__FBSDID("$FreeBSD$");
/* EXP(X)

View File

@ -31,11 +31,9 @@
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)log.c 8.2 (Berkeley) 11/30/93";
#endif /* not lint */
/* @(#)log.c 8.2 (Berkeley) 11/30/93 */
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_log.c,v 1.8 2005/09/19 11:28:19 bde Exp $"); */
__FBSDID("$FreeBSD$");
#include <math.h>
#include <errno.h>

View File

@ -31,11 +31,9 @@
* SUCH DAMAGE.
*/
#ifndef lint
static char sccsid[] = "@(#)gamma.c 8.1 (Berkeley) 6/4/93";
#endif /* not lint */
/* @(#)gamma.c 8.1 (Berkeley) 6/4/93 */
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/lib/msun/bsdsrc/b_tgamma.c,v 1.7 2005/09/19 11:28:19 bde Exp $"); */
__FBSDID("$FreeBSD$");
/*
* This code by P. McIlroy, Oct 1992;
@ -44,14 +42,12 @@ static char sccsid[] = "@(#)gamma.c 8.1 (Berkeley) 6/4/93";
* acknowledged.
*/
//#include <math.h>
#include "../include/math.h"
#include <math.h>
#include "mathimpl.h"
#include <errno.h>
/* METHOD:
* x < 0: Use reflection formula, G(x) = pi/(sin(pi*x)*x*G(x))
* At negative integers, return +Inf, and set errno.
* At negative integers, return NaN and raise invalid.
*
* x < 6.5:
* Use argument reduction G(x+1) = xG(x) to reach the
@ -68,11 +64,15 @@ static char sccsid[] = "@(#)gamma.c 8.1 (Berkeley) 6/4/93";
* avoid premature round-off.
*
* Special values:
* non-positive integer: Set overflow trap; return +Inf;
* x > 171.63: Set overflow trap; return +Inf;
* NaN: Set invalid trap; return NaN
* -Inf: return NaN and raise invalid;
* negative integer: return NaN and raise invalid;
* other x ~< 177.79: return +-0 and raise underflow;
* +-0: return +-Inf and raise divide-by-zero;
* finite x ~> 171.63: return +Inf and raise overflow;
* +Inf: return +Inf;
* NaN: return NaN.
*
* Accuracy: Gamma(x) is accurate to within
* Accuracy: tgamma(x) is accurate to within
* x > 0: error provably < 0.9ulp.
* Maximum observed in 1,000,000 trials was .87ulp.
* x < 0:
@ -133,7 +133,7 @@ tgamma(x)
if (x >= 6) {
if(x > 171.63)
return(one/zero);
return (x / zero);
u = large_gam(x);
return(__exp__D(u.a, u.b));
} else if (x >= 1.0 + LEFT + x0)
@ -141,12 +141,11 @@ tgamma(x)
else if (x > 1.e-17)
return (smaller_gam(x));
else if (x > -1.e-17) {
if (x == 0.0)
return (one/x);
one+1e-20; /* Raise inexact flag. */
if (x != 0.0)
u.a = one - tiny; /* raise inexact */
return (one/x);
} else if (!finite(x))
return (x*x); /* x = NaN, -Inf */
return (x - x); /* x is NaN or -Inf */
else
return (neg_gam(x));
}
@ -280,11 +279,13 @@ neg_gam(x)
struct Double lg, lsine;
double y, z;
y = floor(x + .5);
y = ceil(x);
if (y == x) /* Negative integer. */
return (one/zero);
z = fabs(x - y);
y = .5*ceil(x);
return ((x - x) / zero);
z = y - x;
if (z > 0.5)
z = one - z;
y = 0.5 * y;
if (y == ceil(y))
sgn = -1;
if (z < .25)

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)mathimpl.h 8.1 (Berkeley) 6/4/93
* $FreeBSD: src/lib/msun/bsdsrc/mathimpl.h,v 1.7 2005/11/18 05:03:12 bde Exp $
* $FreeBSD$
*/
#ifndef _MATHIMPL_H_

View File

@ -11,9 +11,8 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_acos.c,v 1.10 2005/02/04 18:26:05 das Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* __ieee754_acos(x)
* Method :
@ -39,14 +38,18 @@ static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_acos.c,v 1.10 2005/02/04 18:
* Function needed: sqrt
*/
#include <float.h>
#include "math.h"
#include "math_private.h"
static const double
one= 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */
pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */
pio2_hi = 1.57079632679489655800e+00; /* 0x3FF921FB, 0x54442D18 */
static volatile double
pio2_lo = 6.12323399573676603587e-17; /* 0x3C91A626, 0x33145C07 */
static const double
pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */
pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */
pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */
@ -102,3 +105,7 @@ __ieee754_acos(double x)
return 2.0*(df+w);
}
}
#if LDBL_MANT_DIG == 53
__weak_reference(acos, acosl);
#endif

View File

@ -13,9 +13,8 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_acosf.c,v 1.7 2002/05/28 17:03:12 alfred Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "math.h"
#include "math_private.h"
@ -23,18 +22,14 @@ static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_acosf.c,v 1.7 2002/05/28 17:
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
pi = 3.1415925026e+00, /* 0x40490fda */
pio2_hi = 1.5707962513e+00, /* 0x3fc90fda */
pio2_lo = 7.5497894159e-08, /* 0x33a22168 */
pS0 = 1.6666667163e-01, /* 0x3e2aaaab */
pS1 = -3.2556581497e-01, /* 0xbea6b090 */
pS2 = 2.0121252537e-01, /* 0x3e4e0aa8 */
pS3 = -4.0055535734e-02, /* 0xbd241146 */
pS4 = 7.9153501429e-04, /* 0x3a4f7f04 */
pS5 = 3.4793309169e-05, /* 0x3811ef08 */
qS1 = -2.4033949375e+00, /* 0xc019d139 */
qS2 = 2.0209457874e+00, /* 0x4001572d */
qS3 = -6.8828397989e-01, /* 0xbf303361 */
qS4 = 7.7038154006e-02; /* 0x3d9dc62e */
pio2_hi = 1.5707962513e+00; /* 0x3fc90fda */
static volatile float
pio2_lo = 7.5497894159e-08; /* 0x33a22168 */
static const float
pS0 = 1.6666586697e-01,
pS1 = -4.2743422091e-02,
pS2 = -8.6563630030e-03,
qS1 = -7.0662963390e-01;
float
__ieee754_acosf(float x)
@ -43,37 +38,38 @@ __ieee754_acosf(float x)
int32_t hx,ix;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if(ix==0x3f800000) { /* |x|==1 */
if(hx>0) return 0.0; /* acos(1) = 0 */
else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */
} else if(ix>0x3f800000) { /* |x| >= 1 */
if(ix>=0x3f800000) { /* |x| >= 1 */
if(ix==0x3f800000) { /* |x| == 1 */
if(hx>0) return 0.0; /* acos(1) = 0 */
else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */
}
return (x-x)/(x-x); /* acos(|x|>1) is NaN */
}
if(ix<0x3f000000) { /* |x| < 0.5 */
if(ix<=0x23000000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/
if(ix<=0x32800000) return pio2_hi+pio2_lo;/*if|x|<2**-26*/
z = x*x;
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
p = z*(pS0+z*(pS1+z*pS2));
q = one+z*qS1;
r = p/q;
return pio2_hi - (x - (pio2_lo-x*r));
} else if (hx<0) { /* x < -0.5 */
z = (one+x)*(float)0.5;
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
s = __ieee754_sqrtf(z);
p = z*(pS0+z*(pS1+z*pS2));
q = one+z*qS1;
s = sqrtf(z);
r = p/q;
w = r*s-pio2_lo;
return pi - (float)2.0*(s+w);
} else { /* x > 0.5 */
int32_t idf;
z = (one-x)*(float)0.5;
s = __ieee754_sqrtf(z);
s = sqrtf(z);
df = s;
GET_FLOAT_WORD(idf,df);
SET_FLOAT_WORD(df,idf&0xfffff000);
c = (z-df*df)/(s+df);
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
p = z*(pS0+z*(pS1+z*pS2));
q = one+z*qS1;
r = p/q;
w = r*s+c;
return (float)2.0*(df+w);

View File

@ -12,9 +12,8 @@
*
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_acosh.c,v 1.8 2005/02/04 18:26:05 das Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* __ieee754_acosh(x)
* Method :

View File

@ -13,9 +13,8 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_acoshf.c,v 1.7 2002/05/28 17:03:12 alfred Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "math.h"
#include "math_private.h"

View File

@ -0,0 +1,87 @@
/* @(#)e_acos.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_acos.c 176451 2008-02-22 02:30:36Z das */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* 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$");
/*
* See comments in e_acos.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
*/
#include <float.h>
#include "invtrig.h"
#include "math.h"
#include "math_private.h"
static const long double
one= 1.00000000000000000000e+00;
#ifdef __i386__
/* XXX Work around the fact that gcc truncates long double constants on i386 */
static volatile double
pi1 = 3.14159265358979311600e+00, /* 0x1.921fb54442d18p+1 */
pi2 = 1.22514845490862001043e-16; /* 0x1.1a80000000000p-53 */
#define pi ((long double)pi1 + pi2)
#else
static const long double
pi = 3.14159265358979323846264338327950280e+00L;
#endif
long double
acosl(long double x)
{
union IEEEl2bits u;
long double z,p,q,r,w,s,c,df;
int16_t expsign, expt;
u.e = x;
expsign = u.xbits.expsign;
expt = expsign & 0x7fff;
if(expt >= BIAS) { /* |x| >= 1 */
if(expt==BIAS && ((u.bits.manh&~LDBL_NBIT)|u.bits.manl)==0) {
if (expsign>0) return 0.0; /* acos(1) = 0 */
else return pi+2.0*pio2_lo; /* acos(-1)= pi */
}
return (x-x)/(x-x); /* acos(|x|>1) is NaN */
}
if(expt<BIAS-1) { /* |x| < 0.5 */
if(expt<ACOS_CONST) return pio2_hi+pio2_lo;/*x tiny: acosl=pi/2*/
z = x*x;
p = P(z);
q = Q(z);
r = p/q;
return pio2_hi - (x - (pio2_lo-x*r));
} else if (expsign<0) { /* x < -0.5 */
z = (one+x)*0.5;
p = P(z);
q = Q(z);
s = sqrtl(z);
r = p/q;
w = r*s-pio2_lo;
return pi - 2.0*(s+w);
} else { /* x > 0.5 */
z = (one-x)*0.5;
s = sqrtl(z);
u.e = s;
u.bits.manl = 0;
df = u.e;
c = (z-df*df)/(s+df);
p = P(z);
q = Q(z);
r = p/q;
w = r*s+c;
return 2.0*(df+w);
}
}

View File

@ -11,9 +11,8 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_asin.c,v 1.11 2005/02/04 18:26:05 das Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* __ieee754_asin(x)
* Method :
@ -45,6 +44,7 @@ static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_asin.c,v 1.11 2005/02/04 18:
*
*/
#include <float.h>
#include "math.h"
#include "math_private.h"
@ -82,14 +82,14 @@ __ieee754_asin(double x)
return x*pio2_hi+x*pio2_lo;
return (x-x)/(x-x); /* asin(|x|>1) is NaN */
} else if (ix<0x3fe00000) { /* |x|<0.5 */
if(ix<0x3e400000) { /* if |x| < 2**-27 */
if(ix<0x3e500000) { /* if |x| < 2**-26 */
if(huge+x>one) return x;/* return x with inexact if x!=0*/
} else
t = x*x;
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
w = p/q;
return x+x*w;
}
t = x*x;
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
w = p/q;
return x+x*w;
}
/* 1> |x|>= 0.5 */
w = one-fabs(x);
@ -111,3 +111,7 @@ __ieee754_asin(double x)
}
if(hx>0) return t; else return -t;
}
#if LDBL_MANT_DIG == 53
__weak_reference(asin, asinl);
#endif

View File

@ -0,0 +1,65 @@
/* e_asinf.c -- float version of e_asin.c.
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* 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.
* ====================================================
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "math.h"
#include "math_private.h"
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
huge = 1.000e+30,
/* coefficient for R(x^2) */
pS0 = 1.6666586697e-01,
pS1 = -4.2743422091e-02,
pS2 = -8.6563630030e-03,
qS1 = -7.0662963390e-01;
static const double
pio2 = 1.570796326794896558e+00;
float
__ieee754_asinf(float x)
{
double s;
float t,w,p,q;
int32_t hx,ix;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if(ix>=0x3f800000) { /* |x| >= 1 */
if(ix==0x3f800000) /* |x| == 1 */
return x*pio2; /* asin(+-1) = +-pi/2 with inexact */
return (x-x)/(x-x); /* asin(|x|>1) is NaN */
} else if (ix<0x3f000000) { /* |x|<0.5 */
if(ix<0x39800000) { /* |x| < 2**-12 */
if(huge+x>one) return x;/* return x with inexact if x!=0*/
}
t = x*x;
p = t*(pS0+t*(pS1+t*pS2));
q = one+t*qS1;
w = p/q;
return x+x*w;
}
/* 1> |x|>= 0.5 */
w = one-fabsf(x);
t = w*(float)0.5;
p = t*(pS0+t*(pS1+t*pS2));
q = one+t*qS1;
s = sqrt(t);
w = p/q;
t = pio2-2.0*(s+s*w);
if(hx>0) return t; else return -t;
}

View File

@ -0,0 +1,77 @@
/* @(#)e_asin.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_asin.c 176451 2008-02-22 02:30:36Z das */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* 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$");
/*
* See comments in e_asin.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
*/
#include <float.h>
#include "invtrig.h"
#include "math.h"
#include "math_private.h"
static const long double
one = 1.00000000000000000000e+00,
huge = 1.000e+300;
long double
asinl(long double x)
{
union IEEEl2bits u;
long double t=0.0,w,p,q,c,r,s;
int16_t expsign, expt;
u.e = x;
expsign = u.xbits.expsign;
expt = expsign & 0x7fff;
if(expt >= BIAS) { /* |x|>= 1 */
if(expt==BIAS && ((u.bits.manh&~LDBL_NBIT)|u.bits.manl)==0)
/* asin(1)=+-pi/2 with inexact */
return x*pio2_hi+x*pio2_lo;
return (x-x)/(x-x); /* asin(|x|>1) is NaN */
} else if (expt<BIAS-1) { /* |x|<0.5 */
if(expt<ASIN_LINEAR) { /* if |x| is small, asinl(x)=x */
if(huge+x>one) return x;/* return x with inexact if x!=0*/
}
t = x*x;
p = P(t);
q = Q(t);
w = p/q;
return x+x*w;
}
/* 1> |x|>= 0.5 */
w = one-fabsl(x);
t = w*0.5;
p = P(t);
q = Q(t);
s = sqrtl(t);
if(u.bits.manh>=THRESH) { /* if |x| is close to 1 */
w = p/q;
t = pio2_hi-(2.0*(s+s*w)-pio2_lo);
} else {
u.e = s;
u.bits.manl = 0;
w = u.e;
c = (t-w*w)/(s+w);
r = p/q;
p = 2.0*s*r-(pio2_lo-2.0*c);
q = pio4_hi-2.0*w;
t = pio4_hi-(p-q);
}
if(expsign>0) return t; else return -t;
}

View File

@ -12,9 +12,8 @@
*
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_atan2.c,v 1.10 2005/02/04 18:26:05 das Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* __ieee754_atan2(y,x)
* Method :
@ -43,15 +42,19 @@ static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_atan2.c,v 1.10 2005/02/04 18
* to produce the hexadecimal values shown.
*/
#include <float.h>
#include "math.h"
#include "math_private.h"
static volatile double
tiny = 1.0e-300;
static const double
tiny = 1.0e-300,
zero = 0.0,
pi_o_4 = 7.8539816339744827900E-01, /* 0x3FE921FB, 0x54442D18 */
pi_o_2 = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */
pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */
pi = 3.1415926535897931160E+00; /* 0x400921FB, 0x54442D18 */
static volatile double
pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
double
@ -68,7 +71,7 @@ __ieee754_atan2(double y, double x)
if(((ix|((lx|-lx)>>31))>0x7ff00000)||
((iy|((ly|-ly)>>31))>0x7ff00000)) /* x or y is NaN */
return x+y;
if(((hx-0x3ff00000) | lx)==0) return atan(y); /* x=1.0 */
if((hx-0x3ff00000|lx)==0) return atan(y); /* x=1.0 */
m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */
/* when y = 0 */
@ -106,19 +109,21 @@ __ieee754_atan2(double y, double x)
/* compute y/x */
k = (iy-ix)>>20;
if(k > 60) z=pi_o_2+0.5*pi_lo; /* |y/x| > 2**60 */
else if(hx<0&&k<-60) z=0.0; /* |y|/x < -2**60 */
if(k > 60) { /* |y/x| > 2**60 */
z=pi_o_2+0.5*pi_lo;
m&=1;
}
else if(hx<0&&k<-60) z=0.0; /* 0 > |y|/x > -2**-60 */
else z=atan(fabs(y/x)); /* safe to do y/x */
switch (m) {
case 0: return z ; /* atan(+,+) */
case 1: {
u_int32_t zh;
GET_HIGH_WORD(zh,z);
SET_HIGH_WORD(z,zh ^ 0x80000000);
}
return z ; /* atan(-,+) */
case 1: return -z ; /* atan(-,+) */
case 2: return pi-(z-pi_lo);/* atan(+,-) */
default: /* case 3 */
return (z-pi_lo)-pi;/* atan(-,-) */
}
}
#if LDBL_MANT_DIG == 53
__weak_reference(atan2, atan2l);
#endif

View File

@ -13,19 +13,20 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_atan2f.c,v 1.7 2004/06/02 17:09:05 bde Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "math.h"
#include "math_private.h"
static volatile float
tiny = 1.0e-30;
static const float
tiny = 1.0e-30,
zero = 0.0,
pi_o_4 = 7.8539818525e-01, /* 0x3f490fdb */
pi_o_2 = 1.5707963705e+00, /* 0x3fc90fdb */
pi = 3.1415927410e+00, /* 0x40490fdb */
pi = 3.1415927410e+00; /* 0x40490fdb */
static volatile float
pi_lo = -8.7422776573e-08; /* 0xb3bbbd2e */
float
@ -79,17 +80,15 @@ __ieee754_atan2f(float y, float x)
/* compute y/x */
k = (iy-ix)>>23;
if(k > 60) z=pi_o_2+(float)0.5*pi_lo; /* |y/x| > 2**60 */
else if(hx<0&&k<-60) z=0.0; /* |y|/x < -2**60 */
if(k > 26) { /* |y/x| > 2**26 */
z=pi_o_2+(float)0.5*pi_lo;
m&=1;
}
else if(k<-26&&hx<0) z=0.0; /* 0 > |y|/x > -2**-26 */
else z=atanf(fabsf(y/x)); /* safe to do y/x */
switch (m) {
case 0: return z ; /* atan(+,+) */
case 1: {
u_int32_t zh;
GET_FLOAT_WORD(zh,z);
SET_FLOAT_WORD(z,zh ^ 0x80000000);
}
return z ; /* atan(-,+) */
case 1: return -z ; /* atan(-,+) */
case 2: return pi-(z-pi_lo);/* atan(+,-) */
default: /* case 3 */
return (z-pi_lo)-pi;/* atan(-,-) */

View File

@ -0,0 +1,120 @@
/* @(#)e_atan2.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_atan2.c 176451 2008-02-22 02:30:36Z das */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* 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$");
/*
* See comments in e_atan2.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
*/
#include <float.h>
#include "invtrig.h"
#include "math.h"
#include "math_private.h"
static volatile long double
tiny = 1.0e-300;
static const long double
zero = 0.0;
#ifdef __i386__
/* XXX Work around the fact that gcc truncates long double constants on i386 */
static volatile double
pi1 = 3.14159265358979311600e+00, /* 0x1.921fb54442d18p+1 */
pi2 = 1.22514845490862001043e-16; /* 0x1.1a80000000000p-53 */
#define pi ((long double)pi1 + pi2)
#else
static const long double
pi = 3.14159265358979323846264338327950280e+00L;
#endif
long double
atan2l(long double y, long double x)
{
union IEEEl2bits ux, uy;
long double z;
int32_t k,m;
int16_t exptx, expsignx, expty, expsigny;
uy.e = y;
expsigny = uy.xbits.expsign;
expty = expsigny & 0x7fff;
ux.e = x;
expsignx = ux.xbits.expsign;
exptx = expsignx & 0x7fff;
if ((exptx==BIAS+LDBL_MAX_EXP &&
((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl)!=0) || /* x is NaN */
(expty==BIAS+LDBL_MAX_EXP &&
((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl)!=0)) /* y is NaN */
return x+y;
if (expsignx==BIAS && ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl)==0)
return atanl(y); /* x=1.0 */
m = ((expsigny>>15)&1)|((expsignx>>14)&2); /* 2*sign(x)+sign(y) */
/* when y = 0 */
if(expty==0 && ((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl)==0) {
switch(m) {
case 0:
case 1: return y; /* atan(+-0,+anything)=+-0 */
case 2: return pi+tiny;/* atan(+0,-anything) = pi */
case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
}
}
/* when x = 0 */
if(exptx==0 && ((ux.bits.manh&~LDBL_NBIT)|ux.bits.manl)==0)
return (expsigny<0)? -pio2_hi-tiny: pio2_hi+tiny;
/* when x is INF */
if(exptx==BIAS+LDBL_MAX_EXP) {
if(expty==BIAS+LDBL_MAX_EXP) {
switch(m) {
case 0: return pio2_hi*0.5+tiny;/* atan(+INF,+INF) */
case 1: return -pio2_hi*0.5-tiny;/* atan(-INF,+INF) */
case 2: return 1.5*pio2_hi+tiny;/*atan(+INF,-INF)*/
case 3: return -1.5*pio2_hi-tiny;/*atan(-INF,-INF)*/
}
} else {
switch(m) {
case 0: return zero ; /* atan(+...,+INF) */
case 1: return -zero ; /* atan(-...,+INF) */
case 2: return pi+tiny ; /* atan(+...,-INF) */
case 3: return -pi-tiny ; /* atan(-...,-INF) */
}
}
}
/* when y is INF */
if(expty==BIAS+LDBL_MAX_EXP)
return (expsigny<0)? -pio2_hi-tiny: pio2_hi+tiny;
/* compute y/x */
k = expty-exptx;
if(k > LDBL_MANT_DIG+2) { /* |y/x| huge */
z=pio2_hi+pio2_lo;
m&=1;
}
else if(expsignx<0&&k<-LDBL_MANT_DIG-2) z=0.0; /* |y/x| tiny, x<0 */
else z=atanl(fabsl(y/x)); /* safe to do y/x */
switch (m) {
case 0: return z ; /* atan(+,+) */
case 1: return -z ; /* atan(-,+) */
case 2: return pi-(z-pi_lo);/* atan(+,-) */
default: /* case 3 */
return (z-pi_lo)-pi;/* atan(-,-) */
}
}

View File

@ -12,9 +12,8 @@
*
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_atanh.c,v 1.7 2005/02/04 18:26:05 das Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* __ieee754_atanh(x)
* Method :

View File

@ -13,9 +13,8 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_atanhf.c,v 1.6 2002/05/28 17:03:12 alfred Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "math.h"
#include "math_private.h"

View File

@ -11,9 +11,8 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_cosh.c,v 1.8 2005/02/04 18:26:05 das Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* __ieee754_cosh(x)
* Method :
@ -46,7 +45,6 @@ __ieee754_cosh(double x)
{
double t,w;
int32_t ix;
u_int32_t lx;
/* High word of |x|. */
GET_HIGH_WORD(ix,x);
@ -73,13 +71,8 @@ __ieee754_cosh(double x)
if (ix < 0x40862E42) return half*__ieee754_exp(fabs(x));
/* |x| in [log(maxdouble), overflowthresold] */
GET_LOW_WORD(lx,x);
if (ix<0x408633CE ||
((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {
w = __ieee754_exp(half*fabs(x));
t = half*w;
return t*w;
}
if (ix<=0x408633CE)
return __ldexp_exp(fabs(x), -1);
/* |x| > overflowthresold, cosh(x) overflow */
return huge*huge;

View File

@ -13,9 +13,8 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_coshf.c,v 1.7 2005/11/13 00:08:23 bde Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "math.h"
#include "math_private.h"
@ -52,11 +51,8 @@ __ieee754_coshf(float x)
if (ix < 0x42b17217) return half*__ieee754_expf(fabsf(x));
/* |x| in [log(maxfloat), overflowthresold] */
if (ix<=0x42b2d4fc) {
w = __ieee754_expf(half*fabsf(x));
t = half*w;
return t*w;
}
if (ix<=0x42b2d4fc)
return __ldexp_expf(fabsf(x), -1);
/* |x| > overflowthresold, cosh(x) overflow */
return huge*huge;

View File

@ -10,9 +10,8 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_exp.c,v 1.10 2005/02/04 18:26:05 das Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* __ieee754_exp(x)
* Returns the exponential of x.
@ -77,6 +76,8 @@ static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_exp.c,v 1.10 2005/02/04 18:2
* to produce the hexadecimal values shown.
*/
#include <float.h>
#include "math.h"
#include "math_private.h"
@ -84,7 +85,6 @@ static const double
one = 1.0,
halF[2] = {0.5,-0.5,},
huge = 1.0e+300,
twom1000= 9.33263618503218878990e-302, /* 2**-1000=0x01700000,0*/
o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
u_threshold= -7.45133219101941108420e+02, /* 0xc0874910, 0xD52D3051 */
ln2HI[2] ={ 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */
@ -98,11 +98,13 @@ P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
static volatile double
twom1000= 9.33263618503218878990e-302; /* 2**-1000=0x01700000,0*/
double
__ieee754_exp(double x) /* default IEEE double exp */
{
double y,hi=0.0,lo=0.0,c,t;
double y,hi=0.0,lo=0.0,c,t,twopk;
int32_t k=0,xsb;
u_int32_t hx;
@ -133,7 +135,7 @@ __ieee754_exp(double x) /* default IEEE double exp */
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
x = hi - lo;
STRICT_ASSIGN(double, x, hi - lo);
}
else if(hx < 0x3e300000) { /* when |x|<2**-28 */
if(huge+x>one) return one+x;/* trigger inexact */
@ -142,18 +144,21 @@ __ieee754_exp(double x) /* default IEEE double exp */
/* x is now in primary range */
t = x*x;
if(k >= -1021)
INSERT_WORDS(twopk,0x3ff00000+(k<<20), 0);
else
INSERT_WORDS(twopk,0x3ff00000+((k+1000)<<20), 0);
c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
if(k==0) return one-((x*c)/(c-2.0)-x);
else y = one-((lo-(x*c)/(2.0-c))-hi);
if(k >= -1021) {
u_int32_t hy;
GET_HIGH_WORD(hy,y);
SET_HIGH_WORD(y,hy+(k<<20)); /* add k to y's exponent */
return y;
if (k==1024) return y*2.0*0x1p1023;
return y*twopk;
} else {
u_int32_t hy;
GET_HIGH_WORD(hy,y);
SET_HIGH_WORD(y,hy+((k+1000)<<20)); /* add k to y's exponent */
return y*twom1000;
return y*twopk*twom1000;
}
}
#if (LDBL_MANT_DIG == 53)
__weak_reference(exp, expl);
#endif

View File

@ -13,9 +13,10 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_expf.c,v 1.10 2005/11/30 04:56:49 bde Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <float.h>
#include "math.h"
#include "math_private.h"
@ -24,7 +25,6 @@ static const float
one = 1.0,
halF[2] = {0.5,-0.5,},
huge = 1.0e+30,
twom100 = 7.8886090522e-31, /* 2**-100=0x0d800000 */
o_threshold= 8.8721679688e+01, /* 0x42b17180 */
u_threshold= -1.0397208405e+02, /* 0xc2cff1b5 */
ln2HI[2] ={ 6.9314575195e-01, /* 0x3f317200 */
@ -32,16 +32,19 @@ ln2HI[2] ={ 6.9314575195e-01, /* 0x3f317200 */
ln2LO[2] ={ 1.4286067653e-06, /* 0x35bfbe8e */
-1.4286067653e-06,}, /* 0xb5bfbe8e */
invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */
P1 = 1.6666667163e-01, /* 0x3e2aaaab */
P2 = -2.7777778450e-03, /* 0xbb360b61 */
P3 = 6.6137559770e-05, /* 0x388ab355 */
P4 = -1.6533901999e-06, /* 0xb5ddea0e */
P5 = 4.1381369442e-08; /* 0x3331bb4c */
/*
* Domain [-0.34568, 0.34568], range ~[-4.278e-9, 4.447e-9]:
* |x*(exp(x)+1)/(exp(x)-1) - p(x)| < 2**-27.74
*/
P1 = 1.6666625440e-1, /* 0xaaaa8f.0p-26 */
P2 = -2.7667332906e-3; /* -0xb55215.0p-32 */
static volatile float twom100 = 7.8886090522e-31; /* 2**-100=0x0d800000 */
float
__ieee754_expf(float x) /* default IEEE double exp */
__ieee754_expf(float x)
{
float y,hi=0.0,lo=0.0,c,t;
float y,hi=0.0,lo=0.0,c,t,twopk;
int32_t k=0,xsb;
u_int32_t hx;
@ -69,27 +72,26 @@ __ieee754_expf(float x) /* default IEEE double exp */
hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
lo = t*ln2LO[0];
}
x = hi - lo;
STRICT_ASSIGN(float, x, hi - lo);
}
else if(hx < 0x31800000) { /* when |x|<2**-28 */
else if(hx < 0x39000000) { /* when |x|<2**-14 */
if(huge+x>one) return one+x;/* trigger inexact */
}
else k = 0;
/* x is now in primary range */
t = x*x;
c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
if(k >= -125)
SET_FLOAT_WORD(twopk,0x3f800000+(k<<23));
else
SET_FLOAT_WORD(twopk,0x3f800000+((k+100)<<23));
c = x - t*(P1+t*P2);
if(k==0) return one-((x*c)/(c-(float)2.0)-x);
else y = one-((lo-(x*c)/((float)2.0-c))-hi);
if(k >= -125) {
u_int32_t hy;
GET_FLOAT_WORD(hy,y);
SET_FLOAT_WORD(y,hy+(k<<23)); /* add k to y's exponent */
return y;
if(k==128) return y*2.0F*0x1p127F;
return y*twopk;
} else {
u_int32_t hy;
GET_FLOAT_WORD(hy,y);
SET_FLOAT_WORD(y,hy+((k+100)<<23)); /* add k to y's exponent */
return y*twom100;
return y*twopk*twom100;
}
}

View File

@ -11,9 +11,8 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_fmod.c,v 1.9 2005/02/04 18:26:05 das Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* __ieee754_fmod(x,y)

View File

@ -13,9 +13,8 @@
* ====================================================
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_fmodf.c,v 1.6 2002/05/28 17:03:12 alfred Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* __ieee754_fmodf(x,y)

View File

@ -0,0 +1,149 @@
/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* 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$");
#include <float.h>
#include <stdint.h>
#include "fpmath.h"
#include "math.h"
#include "math_private.h"
#define BIAS (LDBL_MAX_EXP - 1)
#if LDBL_MANL_SIZE > 32
typedef uint64_t manl_t;
#else
typedef uint32_t manl_t;
#endif
#if LDBL_MANH_SIZE > 32
typedef uint64_t manh_t;
#else
typedef uint32_t manh_t;
#endif
/*
* These macros add and remove an explicit integer bit in front of the
* fractional mantissa, if the architecture doesn't have such a bit by
* default already.
*/
#ifdef LDBL_IMPLICIT_NBIT
#define SET_NBIT(hx) ((hx) | (1ULL << LDBL_MANH_SIZE))
#define HFRAC_BITS LDBL_MANH_SIZE
#else
#define SET_NBIT(hx) (hx)
#define HFRAC_BITS (LDBL_MANH_SIZE - 1)
#endif
#define MANL_SHIFT (LDBL_MANL_SIZE - 1)
static const long double one = 1.0, Zero[] = {0.0, -0.0,};
/*
* fmodl(x,y)
* Return x mod y in exact arithmetic
* Method: shift and subtract
*
* Assumptions:
* - The low part of the mantissa fits in a manl_t exactly.
* - The high part of the mantissa fits in an int64_t with enough room
* for an explicit integer bit in front of the fractional bits.
*/
long double
fmodl(long double x, long double y)
{
union IEEEl2bits ux, uy;
int64_t hx,hz; /* We need a carry bit even if LDBL_MANH_SIZE is 32. */
manh_t hy;
manl_t lx,ly,lz;
int ix,iy,n,sx;
ux.e = x;
uy.e = y;
sx = ux.bits.sign;
/* purge off exception values */
if((uy.bits.exp|uy.bits.manh|uy.bits.manl)==0 || /* y=0 */
(ux.bits.exp == BIAS + LDBL_MAX_EXP) || /* or x not finite */
(uy.bits.exp == BIAS + LDBL_MAX_EXP &&
((uy.bits.manh&~LDBL_NBIT)|uy.bits.manl)!=0)) /* or y is NaN */
return (x*y)/(x*y);
if(ux.bits.exp<=uy.bits.exp) {
if((ux.bits.exp<uy.bits.exp) ||
(ux.bits.manh<=uy.bits.manh &&
(ux.bits.manh<uy.bits.manh ||
ux.bits.manl<uy.bits.manl))) {
return x; /* |x|<|y| return x or x-y */
}
if(ux.bits.manh==uy.bits.manh && ux.bits.manl==uy.bits.manl) {
return Zero[sx]; /* |x|=|y| return x*0*/
}
}
/* determine ix = ilogb(x) */
if(ux.bits.exp == 0) { /* subnormal x */
ux.e *= 0x1.0p512;
ix = ux.bits.exp - (BIAS + 512);
} else {
ix = ux.bits.exp - BIAS;
}
/* determine iy = ilogb(y) */
if(uy.bits.exp == 0) { /* subnormal y */
uy.e *= 0x1.0p512;
iy = uy.bits.exp - (BIAS + 512);
} else {
iy = uy.bits.exp - BIAS;
}
/* set up {hx,lx}, {hy,ly} and align y to x */
hx = SET_NBIT(ux.bits.manh);
hy = SET_NBIT(uy.bits.manh);
lx = ux.bits.manl;
ly = uy.bits.manl;
/* fix point fmod */
n = ix - iy;
while(n--) {
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
if(hz<0){hx = hx+hx+(lx>>MANL_SHIFT); lx = lx+lx;}
else {
if ((hz|lz)==0) /* return sign(x)*0 */
return Zero[sx];
hx = hz+hz+(lz>>MANL_SHIFT); lx = lz+lz;
}
}
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
if(hz>=0) {hx=hz;lx=lz;}
/* convert back to floating value and restore the sign */
if((hx|lx)==0) /* return sign(x)*0 */
return Zero[sx];
while(hx<(1ULL<<HFRAC_BITS)) { /* normalize x */
hx = hx+hx+(lx>>MANL_SHIFT); lx = lx+lx;
iy -= 1;
}
ux.bits.manh = hx; /* The mantissa is truncated here if needed. */
ux.bits.manl = lx;
if (iy < LDBL_MIN_EXP) {
ux.bits.exp = iy + (BIAS + 512);
ux.e *= 0x1p-512;
} else {
ux.bits.exp = iy + BIAS;
}
x = ux.e * one; /* create necessary signal */
return x; /* exact output */
}

View File

@ -12,9 +12,8 @@
*
*/
#ifndef lint
static char rcsid[] = "$FreeBSD: src/lib/msun/src/e_gamma.c,v 1.7 2005/02/04 18:26:05 das Exp $";
#endif
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* __ieee754_gamma(x)
* Return the logarithm of the Gamma function of x.

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