diff options
| author | David Schultz <das@FreeBSD.org> | 2005-03-01 04:03:58 +0000 |
|---|---|---|
| committer | David Schultz <das@FreeBSD.org> | 2005-03-01 04:03:58 +0000 |
| commit | e514a90512169fe1fa1fc3a0fc4a95b8f8b9c6ea (patch) | |
| tree | aff94fbf5e87048661f21d99c116e29981d57acb /lib/msun | |
| parent | 0ccc485183b741f7da8db0a51e04cc6dcbe99ba9 (diff) | |
Notes
Diffstat (limited to 'lib/msun')
| -rw-r--r-- | lib/msun/man/acos.3 | 15 | ||||
| -rw-r--r-- | lib/msun/man/acosh.3 | 16 | ||||
| -rw-r--r-- | lib/msun/man/asin.3 | 17 | ||||
| -rw-r--r-- | lib/msun/man/atan2.3 | 22 | ||||
| -rw-r--r-- | lib/msun/man/atanh.3 | 21 | ||||
| -rw-r--r-- | lib/msun/man/ceil.3 | 18 | ||||
| -rw-r--r-- | lib/msun/man/cimag.3 | 28 | ||||
| -rw-r--r-- | lib/msun/man/cosh.3 | 14 | ||||
| -rw-r--r-- | lib/msun/man/exp.3 | 62 | ||||
| -rw-r--r-- | lib/msun/man/feclearexcept.3 | 4 | ||||
| -rw-r--r-- | lib/msun/man/fegetround.3 | 6 | ||||
| -rw-r--r-- | lib/msun/man/fenv.3 | 28 | ||||
| -rw-r--r-- | lib/msun/man/floor.3 | 18 | ||||
| -rw-r--r-- | lib/msun/man/fmax.3 | 7 | ||||
| -rw-r--r-- | lib/msun/man/hypot.3 | 11 | ||||
| -rw-r--r-- | lib/msun/man/ieee.3 | 560 | ||||
| -rw-r--r-- | lib/msun/man/j0.3 | 18 | ||||
| -rw-r--r-- | lib/msun/man/lgamma.3 | 10 | ||||
| -rw-r--r-- | lib/msun/man/math.3 | 528 | ||||
| -rw-r--r-- | lib/msun/man/sinh.3 | 15 | ||||
| -rw-r--r-- | lib/msun/man/sqrt.3 | 42 |
21 files changed, 647 insertions, 813 deletions
diff --git a/lib/msun/man/acos.3 b/lib/msun/man/acos.3 index 6004f32d4afe..a08230a890fe 100644 --- a/lib/msun/man/acos.3 +++ b/lib/msun/man/acos.3 @@ -32,7 +32,7 @@ .\" from: @(#)acos.3 5.1 (Berkeley) 5/2/91 .\" $FreeBSD$ .\" -.Dd May 2, 1991 +.Dd January 14, 2005 .Dt ACOS 3 .Os .Sh NAME @@ -66,27 +66,20 @@ and the functions return the arc cosine in the range .Bq 0 , \*(Pi radians. -On the -.Tn VAX -and -.Tn Tahoe , -if: +If: .Bd -unfilled -offset indent .Pf \&| Ns Ar x Ns \&| > 1 , .Ed .Pp .Fn acos x -sets the global variable -.Va errno -to -.Er EDOM -and a reserved operand fault is generated. +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 , diff --git a/lib/msun/man/acosh.3 b/lib/msun/man/acosh.3 index 2eb82d13dadc..b1339013889d 100644 --- a/lib/msun/man/acosh.3 +++ b/lib/msun/man/acosh.3 @@ -32,7 +32,7 @@ .\" from: @(#)acosh.3 5.2 (Berkeley) 5/6/91 .\" $FreeBSD$ .\" -.Dd May 6, 1991 +.Dd January 14, 2005 .Dt ACOSH 3 .Os .Sh NAME @@ -66,22 +66,14 @@ and the functions return the inverse hyperbolic cosine of .Ar x . -On the -.Tn VAX -and -.Tn Tahoe , -if the argument is less than one +If the argument is less than 1, .Fn acosh -sets the global variable -.Va errno -to -.Er EDOM -and -causes a reserved operand fault. +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 diff --git a/lib/msun/man/asin.3 b/lib/msun/man/asin.3 index f3ec7ac71208..e33623d74db3 100644 --- a/lib/msun/man/asin.3 +++ b/lib/msun/man/asin.3 @@ -32,7 +32,7 @@ .\" from: @(#)asin.3 5.1 (Berkeley) 5/2/91 .\" $FreeBSD$ .\" -.Dd May 2, 1991 +.Dd January 14, 2005 .Dt ASIN 3 .Os .Sh NAME @@ -68,27 +68,20 @@ functions return the arc sine in the range .Bq -\*(Pi/2 , +\*(Pi/2 .Ek radians. -On the -.Tn VAX , -and Tahoe, -if: +If: .Bd -unfilled -offset indent .Pf \&| Ns Ar x Ns \&| > 1 .Ed .Pp -the -global variable -.Va errno -is set to -.Er EDOM -and -a reserved operand fault generated. +.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 , diff --git a/lib/msun/man/atan2.3 b/lib/msun/man/atan2.3 index f951812bab0c..684124b5043b 100644 --- a/lib/msun/man/atan2.3 +++ b/lib/msun/man/atan2.3 @@ -32,7 +32,7 @@ .\" from: @(#)atan2.3 5.1 (Berkeley) 5/2/91 .\" $FreeBSD$ .\" -.Dd May 2, 1991 +.Dd January 14, 2005 .Dt ATAN2 3 .Os .Sh NAME @@ -69,16 +69,7 @@ in the range .Bq \&- Ns \*(Pi , \&+ Ns \*(Pi .Ek radians. -If both -.Fa x -and -.Fa y -are zero, the global variable -.Va errno -is set to -.Er EDOM . -On the -.Tn VAX : +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 @@ -105,9 +96,7 @@ The function .Fn atan2 defines "if x > 0," .Fn atan2 0 0 -= 0 on a -.Tn VAX -despite that previously += 0 despite that previously .Fn atan2 0 0 may have generated an error message. The reasons for assigning a value to @@ -142,10 +131,9 @@ r\(**sin\(*h. These equations are satisfied when (x=0,y=0) is mapped to .if n \ -(r=0,theta=0) +(r=0,theta=0). .if t \ -(r=0,\(*h=0) -on a VAX. +(r=0,\(*h=0). In general, conversions to polar coordinates should be computed thus: .Bd -unfilled -offset indent diff --git a/lib/msun/man/atanh.3 b/lib/msun/man/atanh.3 index cd9f276ce19f..abd0c7d91293 100644 --- a/lib/msun/man/atanh.3 +++ b/lib/msun/man/atanh.3 @@ -32,7 +32,7 @@ .\" from: @(#)atanh.3 5.2 (Berkeley) 5/6/91 .\" $FreeBSD$ .\" -.Dd May 6, 1991 +.Dd January 14, 2005 .Dt ATANH 3 .Os .Sh NAME @@ -67,23 +67,16 @@ functions return the inverse hyperbolic tangent of .Ar x if successful. -On the -.Tn VAX -and -.Tn Tahoe , -if the argument has absolute value -bigger than or equal to 1, -.Fn atanh -sets the global variable -.Va errno -to -.Er EDOM -and -a reserved operand fault is generated. +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 diff --git a/lib/msun/man/ceil.3 b/lib/msun/man/ceil.3 index 15b0ff48ec53..3f825c911dd8 100644 --- a/lib/msun/man/ceil.3 +++ b/lib/msun/man/ceil.3 @@ -32,12 +32,13 @@ .\" from: @(#)ceil.3 5.1 (Berkeley) 5/2/91 .\" $FreeBSD$ .\" -.Dd March 10, 1994 +.Dd January 13, 2005 .Dt CEIL 3 .Os .Sh NAME .Nm ceil , -.Nm ceilf +.Nm ceilf , +.Nm ceill .Nd smallest integral value greater than or equal to x .Sh LIBRARY .Lb libm @@ -47,11 +48,14 @@ .Fn ceil "double x" .Ft float .Fn ceilf "float x" +.Ft "long double" +.Fn ceill "long double x" .Sh DESCRIPTION The -.Fn ceil -and the +.Fn ceil , .Fn ceilf +and +.Fn ceill functions return the smallest integral value greater than or equal to .Fa x , @@ -70,3 +74,9 @@ The .Fn ceil function conforms to .St -isoC . +The +.Fn ceilf +and +.Fn ceill +functions conform to +.St -isoC-99 . diff --git a/lib/msun/man/cimag.3 b/lib/msun/man/cimag.3 index 8fe3cc4afec8..10a3b2cb405e 100644 --- a/lib/msun/man/cimag.3 +++ b/lib/msun/man/cimag.3 @@ -24,20 +24,14 @@ .\" .\" $FreeBSD$ .\" -.Dd Aug 7, 2004 +.Dd August 7, 2004 .Dt CIMAG 3 .Os .Sh NAME -.Nm cimag , -.Nm cimagf , -.Nm cimagl , -.Nm conj , -.Nm conjf , -.Nm conjl , -.Nm creal , -.Nm crealf , -.Nm creall -.Nd functions to manipulate complex numbers +.Nm cimag , cimagf , cimagl , +.Nm conj , conjf , conjl , +.Nm creal , crealf , creall +.Nd "functions to manipulate complex numbers" .Sh LIBRARY .Lb libm .Sh SYNOPSIS @@ -46,19 +40,19 @@ .Fn cimag "double complex z" .Ft float .Fn cimagf "float complex z" -.Ft long double +.Ft "long double" .Fn cimagl "long double complex z" -.Ft double complex +.Ft "double complex" .Fn conj "double complex z" -.Ft float complex +.Ft "float complex" .Fn conjf "float complex z" -.Ft long double complex +.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 +.Ft "long double" .Fn creall "long double complex z" .Sh DESCRIPTION Let @@ -66,7 +60,7 @@ Let .Fa a + b * Em i .Sm on denote the complex number -.Ar z . +.Fa z . .Pp The .Fn cimag diff --git a/lib/msun/man/cosh.3 b/lib/msun/man/cosh.3 index d2b28249b8a0..74744d4e335a 100644 --- a/lib/msun/man/cosh.3 +++ b/lib/msun/man/cosh.3 @@ -32,7 +32,7 @@ .\" from: @(#)cosh.3 5.1 (Berkeley) 5/2/91 .\" $FreeBSD$ .\" -.Dd May 2, 1991 +.Dd January 14, 2005 .Dt COSH 3 .Os .Sh NAME @@ -54,18 +54,6 @@ and the .Fn coshf functions compute the hyperbolic cosine of .Fa x . -.Sh RETURN VALUES -The -.Fn cosh -and the -.Fn coshf -functions return the hyperbolic cosine unless the magnitude -of -.Fa x -is too large; in this event, the global variable -.Va errno -is set to -.Er ERANGE . .Sh SEE ALSO .Xr acos 3 , .Xr asin 3 , diff --git a/lib/msun/man/exp.3 b/lib/msun/man/exp.3 index 62e9e3e1b301..d1ba7da800ee 100644 --- a/lib/msun/man/exp.3 +++ b/lib/msun/man/exp.3 @@ -32,14 +32,12 @@ .\" from: @(#)exp.3 6.12 (Berkeley) 7/31/91 .\" $FreeBSD$ .\" -.Dd July 31, 1991 +.Dd January 14, 2005 .Dt EXP 3 .Os .Sh NAME .Nm exp , .Nm expf , -.Nm exp10 , -.Nm exp10f , .Nm expm1 , .Nm expm1f , .Nm log , @@ -182,49 +180,18 @@ is exact until it is bigger than 2**56 on a These functions will return the appropriate computation unless an error occurs or an argument is out of range. The functions -.Fn exp , -.Fn expm1 , -.Fn pow -detect if the computed value will overflow, -set the global variable -.Va errno -to -.Er ERANGE -and cause a reserved operand fault on a -.Tn VAX -or -.Tn Tahoe . -The functions .Fn pow x y -checks to see if +and +.Fn powf x y +raise an invalid exception and return an \*(Na if .Fa x < 0 and .Fa y -is not an integer, in the event this is true, -the global variable -.Va errno -is set to -.Er EDOM -and on the -.Tn VAX -and -.Tn Tahoe -generate a reserved operand fault. -On a -.Tn VAX -and -.Tn Tahoe , -.Va errno -is set to -.Er EDOM -and the reserved operand is returned -by log unless -.Fa x -> 0, by -.Fn log1p -unless -.Fa x -> \-1. +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 @@ -248,10 +215,7 @@ They also provide accurate inverse hyperbolic functions. The function .Fn pow x 0 returns x**0 = 1 for all x including x = 0, -.if n \ -Infinity -.if t \ -\(if +\*(If (not found on a .Tn VAX ) , and @@ -296,14 +260,12 @@ x(0) = y(0) = 0, then x(z)**y(z) \(-> 1 as z \(-> 0. .Ed .It If 0**0 = 1, then -.if n \ -infinity**0 = 1/0**0 = 1 too; and -.if t \ -\(if**0 = 1/0**0 = 1 too; and +\*(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 .Sh HISTORY A diff --git a/lib/msun/man/feclearexcept.3 b/lib/msun/man/feclearexcept.3 index 324f142539bb..217642c858e7 100644 --- a/lib/msun/man/feclearexcept.3 +++ b/lib/msun/man/feclearexcept.3 @@ -58,7 +58,9 @@ whereas .Fn feraiseexcept raises the specified exceptions. Raising an exception causes the corresponding flag to be set, -and a SIGFPE is delivered to the process if the exception is unmasked. +and a +.Dv SIGFPE +is delivered to the process if the exception is unmasked. .Pp The .Fn fetestexcept diff --git a/lib/msun/man/fegetround.3 b/lib/msun/man/fegetround.3 index 1461c83cca87..c6cd417dc9ad 100644 --- a/lib/msun/man/fegetround.3 +++ b/lib/msun/man/fegetround.3 @@ -37,7 +37,7 @@ .In fenv.h .Fd "#pragma STDC FENV_ACCESS ON" .Ft int -.Fn fegetround "void" +.Fn fegetround void .Ft int .Fn fesetround "int round" .Sh DESCRIPTION @@ -49,9 +49,7 @@ and the function sets the current rounding mode to .Fa round . The rounding mode is one of -.Dv FE_TONEAREST , -.Dv FE_DOWNWARD , -.Dv FE_UPWARD , +.Dv FE_TONEAREST , FE_DOWNWARD , FE_UPWARD , or .Dv FE_TOWARDZERO , as described in diff --git a/lib/msun/man/fenv.3 b/lib/msun/man/fenv.3 index 4d277129dadf..7c6de1f7f11a 100644 --- a/lib/msun/man/fenv.3 +++ b/lib/msun/man/fenv.3 @@ -56,7 +56,7 @@ .Ft int .Fn fetestexcept "int excepts" .Ft int -.Fn fegetround "void" +.Fn fegetround void .Ft int .Fn fesetround "int round" .Ft int @@ -68,7 +68,9 @@ .Ft int .Fn feupdateenv "const fenv_t *envp" .Sh DESCRIPTION -The fenv routines manipulate the floating-point environment, +The +.In fenv.h +routines manipulate the floating-point environment, which includes the exception flags and rounding modes defined in .St -ieee754 . .Ss Exceptions @@ -79,25 +81,23 @@ 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" +.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" +.It Dv FE_INEXACT An inexact exception is raised whenever there is a loss of precision due to rounding. -.It Dv "FE_INVALID" +.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 -.Na -s, and taking the square root of a +ordered comparison involving \*(Nas, and taking the square root of a negative number are all invalid operations. -.It Dv "FE_OVERFLOW" +.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" +.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 @@ -123,16 +123,16 @@ 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" +.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" +.It Dv FE_DOWNWARD Results are rounded towards negative \*[If]. -.It Dv "FE_UPWARD" +.It Dv FE_UPWARD Results are rounded towards positive \*[If]. -.It Dv "FE_TOWARDZERO" +.It Dv FE_TOWARDZERO Results are rounded towards zero. .El .Pp diff --git a/lib/msun/man/floor.3 b/lib/msun/man/floor.3 index f9a722f54c00..ed46689cf43c 100644 --- a/lib/msun/man/floor.3 +++ b/lib/msun/man/floor.3 @@ -32,12 +32,13 @@ .\" from: @(#)floor.3 6.5 (Berkeley) 4/19/91 .\" $FreeBSD$ .\" -.Dd March 10, 1994 +.Dd January 13, 2005 .Dt FLOOR 3 .Os .Sh NAME .Nm floor , -.Nm floorf +.Nm floorf , +.Nm floorl .Nd largest integral value less than or equal to x .Sh LIBRARY .Lb libm @@ -47,11 +48,14 @@ .Fn floor "double x" .Ft float .Fn floorf "float x" +.Ft "long double" +.Fn floorl "long double x" .Sh DESCRIPTION The -.Fn floor -and +.Fn floor , .Fn floorf +and +.Fn floorl functions return the largest integral value less than or equal to .Fa x , @@ -70,3 +74,9 @@ The .Fn floor function conforms to .St -isoC . +The +.Fn floorf +and +.Fn floorl +functions conform to +.St -isoC-99 . diff --git a/lib/msun/man/fmax.3 b/lib/msun/man/fmax.3 index a5ed8e60e3fa..71cb7d932f36 100644 --- a/lib/msun/man/fmax.3 +++ b/lib/msun/man/fmax.3 @@ -43,13 +43,13 @@ .Fn fmax "double x" "double y" .Ft float .Fn fmaxf "float x" "float y" -.Ft long double +.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 +.Ft "long double" .Fn fminl "long double x" "long double y" .Sh DESCRIPTION The @@ -70,8 +70,9 @@ functions return the smaller of .Fa x and .Fa y . +They treat .Li +0.0 -is treated as being larger than +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. diff --git a/lib/msun/man/hypot.3 b/lib/msun/man/hypot.3 index 312457878d1f..4843e4418373 100644 --- a/lib/msun/man/hypot.3 +++ b/lib/msun/man/hypot.3 @@ -32,7 +32,7 @@ .\" from: @(#)hypot.3 6.7 (Berkeley) 5/6/91 .\" $FreeBSD$ .\" -.Dd May 6, 1991 +.Dd January 14, 2005 .Dt HYPOT 3 .Os .Sh NAME @@ -98,13 +98,8 @@ and .Fn hypot "\*(Na" "v" are \*(Na for all .Em finite -.Fa v ; -with "reserved operand" in place of "\*(Na", the -same is true on a -.Tn VAX . -But programmers on machines other than a -.Tn VAX -(if has no \*(If) +.Fa v . +But programmers might be surprised at first to discover that .Fn hypot "\(+-\*(If" "\*(Na" = +\*(If. diff --git a/lib/msun/man/ieee.3 b/lib/msun/man/ieee.3 index 73a39f689465..291ccd8b6b5d 100644 --- a/lib/msun/man/ieee.3 +++ b/lib/msun/man/ieee.3 @@ -1,4 +1,4 @@ -.\" Copyright (c) 1985, 1991 Regents of the University of California. +.\" Copyright (c) 1985 Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -32,177 +32,419 @@ .\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91 .\" $FreeBSD$ .\" -.Dd June 20, 2004 +.Dd January 26, 2005 .Dt IEEE 3 .Os .Sh NAME -.Nm copysign , -.Nm copysignf , -.Nm copysignl , -.Nm finite , -.Nm finitef , -.Nm ilogb , -.Nm ilogbf , -.Nm nextafter , -.Nm nextafterf , -.Nm remainder , -.Nm remainderf , -.Nm scalbln , -.Nm scalblnf , -.Nm scalbn , -.Nm scalbnf -.Nd functions for IEEE arithmetic -.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" -.Ft int -.Fn finite "double x" -.Ft int -.Fn finitef "float x" -.Ft int -.Fn ilogb "double x" -.Ft int -.Fn ilogbf "float x" -.Ft double -.Fn nextafter "double x" "double y" -.Ft float -.Fn nextafterf "float x" "float y" -.Ft double -.Fn remainder "double x" "double y" -.Ft float -.Fn remainderf "float x" "float y" -.Ft double -.Fn scalbln "double x" "long n" -.Ft float -.Fn scalblnf "float x" "long n" -.Ft double -.Fn scalbn "double x" "int n" -.Ft float -.Fn scalbnf "float x" "int n" +.Nm ieee +.Nd IEEE standard 754 for floating-point arithmetic .Sh DESCRIPTION -These functions are required or recommended by -.St -ieee754 . +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 -The -.Fn copysign , -.Fn copysignf -and -.Fn copysignl -functions -return -.Fa x -with its sign changed to -.Fa y Ns 's . +.Bl -column "" -compact +Overflow and underflow: +.El +.Bd -ragged -offset indent -compact +Overflow goes by default to a signed \*(If. +Underflow is +.Em gradual . +.Ed .Pp -.Fn finite -and -.Fn finitef -return the value 1 just when -\-\*(If \*(Lt -.Fa x -\*(Lt +\*(If; -otherwise a -zero is returned -(when -.Pf \\*(Ba Ns Fa x Ns \\*(Ba -= \*(If or -.Fa x -is \*(Na). +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 -.Fn ilogb -and -.Fn ilogbf -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 . +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 -.Fn nextafter -and -.Fn nextafterf -return the next machine representable number from -.Fa x -in direction -.Fa y . +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 -.Fn remainder -and -.Fn remainderf -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 +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 -.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 -.Fn remainder x 0 -and -.Fn remainder \*(If 0 -are invalid operations that produce a \*(Na. +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**16451 = 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 -.Fn scalbln , -.Fn scalblnf , -.Fn scalbn , +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 scalbnf -return -.Fa x Ns \(**(2** Ns Fa n ) -computed by exponent manipulation. +.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 -.Sh HISTORY -The -.Nm ieee -functions appeared in -.Bx 4.3 . -The -.Fn copysignl , -.Fn scalbln , -and -.Fn scalblnf -functions first appeared in -.Fx 5.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 diff --git a/lib/msun/man/j0.3 b/lib/msun/man/j0.3 index 006119fcbaa7..2d8081084cdd 100644 --- a/lib/msun/man/j0.3 +++ b/lib/msun/man/j0.3 @@ -32,7 +32,7 @@ .\" from: @(#)j0.3 6.7 (Berkeley) 4/19/91 .\" $FreeBSD$ .\" -.Dd April 19, 1991 +.Dd January 14, 2005 .Dt J0 3 .Os .Sh NAME @@ -134,22 +134,6 @@ value .Sh RETURN VALUES If these functions are successful, the computed value is returned. -On the -.Tn VAX -and -.Tn Tahoe -architectures, -for the Bessel functions of the second kind, -a negative -or zero -.Fa x -value -results in an error; the global -variable -.Va errno -is set to -.Er EDOM -and a reserve operand fault is generated. .Sh SEE ALSO .Xr math 3 .Sh HISTORY diff --git a/lib/msun/man/lgamma.3 b/lib/msun/man/lgamma.3 index e950908ce6f4..f7812c9f8f1a 100644 --- a/lib/msun/man/lgamma.3 +++ b/lib/msun/man/lgamma.3 @@ -32,7 +32,7 @@ .\" from: @(#)lgamma.3 6.6 (Berkeley) 12/3/92 .\" $FreeBSD$ .\" -.Dd December 3, 1992 +.Dd January 14, 2005 .Dt LGAMMA 3 .Os .Sh NAME @@ -79,7 +79,6 @@ and 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 -.br \(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. .Ed .\} @@ -149,13 +148,6 @@ and return appropriate values unless an argument is out of range. Overflow will occur for sufficiently large positive values, and non-positive integers. -On the -.Tn VAX , -the reserved operator is returned, -and -.Va errno -is set to -.Er ERANGE . For large non-integer negative values, .Fn tgamma will underflow. diff --git a/lib/msun/man/math.3 b/lib/msun/man/math.3 index a5cafd9c1ff3..0b622b4a0a52 100644 --- a/lib/msun/man/math.3 +++ b/lib/msun/man/math.3 @@ -36,7 +36,6 @@ .Dt MATH 3 .Os .if n \{\ -.char \[if] "Infinity .char \[sr] "sqrt .\} .Sh NAME @@ -74,409 +73,136 @@ and .Ft "long double" .Fn acosl "long double x" , respectively. -.Pp -The programs are accurate to within the numbers -of -.Em ulp Ns s -tabulated below; an -.Em ulp -is one -.Em U Ns nit -in the -.Em L Ns ast -.Em P Ns lace . -.Bl -column "nexttoward" "remainder with partial quotient" -.Em "Name Description Error Bound (ULPs)" -.\" XXX Many of these error bounds are wrong for the current implementation! -acos inverse trigonometric function ??? -acosh inverse hyperbolic function ??? -asin inverse trigonometric function ??? -asinh inverse hyperbolic function ??? -atan inverse trigonometric function ??? -atanh inverse hyperbolic function ??? -atan2 inverse trigonometric function ??? -cbrt cube root 1 -ceil integer no less than 0 -copysign copy sign bit 0 -cos trigonometric function 1 -cosh hyperbolic function ??? -erf error function 1 -erfc complementary error function 1 -exp exponential base e 1 -.\" exp2 exponential base 2 ??? -expm1 exp(x)\-1 1 -fabs absolute value 0 -fdim positive difference 1 -floor integer no greater than 0 -.\" fma multiply-add ??? -fmax maximum function 0 -fmin minimum function 0 -fmod remainder function ??? -frexp extract mantissa and exponent 0 -hypot Euclidean distance 1 -ilogb exponent extraction 0 -j0 bessel function ??? -j1 bessel function ??? -jn bessel function ??? -ldexp multiply by power of 2 0 -lgamma log gamma function 1 -llrint round to integer 0 -llround round to nearest integer 0 -log natural logarithm 1 -log10 logarithm to base 10 1 -log1p log(1+x) 1 -.\" log2 base 2 logarithm 0 -logb exponent extraction 0 -lrint round to integer 0 -lround round to nearest integer 0 -modf extract fractional part 0 -.\" nan return quiet \*(Na) 0 -nearbyint round to integer 0 -nextafter next representable value 0 -.\" nexttoward next representable value 0 -pow exponential x**y 60-500 -remainder remainder 0 -.\" remquo remainder with partial quotient ??? -rint round to nearest integer 0 -round round to nearest integer 0 -scalbln exponent adjustment 0 -scalbn exponent adjustment 0 -sin trigonometric function 1 -sinh hyperbolic function ??? -sqrt square root 1 -tan trigonometric function 1 -tanh hyperbolic function ??? -tgamma gamma function 1 -trunc round towards zero 0 -y0 bessel function ??? -y1 bessel function ??? -yn bessel function ??? -.El -.Sh NOTES -Virtually all modern floating-point units attempt to support -IEEE Standard 754 for Binary Floating-Point Arithmetic. -This standard does not cover particular routines in the math library -except for the few documented in -.Xr ieee 3 ; -it primarily defines representations of numbers and abstract -properties of arithmetic operations relating to precision, rounding, -and exceptional cases, as described below. -.Ss IEEE STANDARD 754 Floating-Point Arithmetic -.\" XXX mention single- and extended-/quad- precisions -Properties of IEEE 754 Double-Precision: -.Bd -ragged -offset indent -compact -Wordsize: 64 bits, 8 bytes. -.Pp -Radix: Binary. -.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 -Overflow goes by default to a signed \*(if. -Underflow is -.Em Gradual , -rounding to the nearest -integer multiple of 0.5**1074 = 4.9e\-324. -.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 -\*(if 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: -.Bd -ragged -offset indent -compact -there are 2**53\-2 of them, all -called \*(Na -.Em ( N Ns ot Em a N Ns umber ) . -Some, 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. -.Pp -NOTE: Trichotomy is violated by \*(Na. -Besides being FALSE, predicates that entail ordered -comparison, rather than mere (in)equality, -signal Invalid Operation when \*(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. -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. -And the -same kinds of rounding are specified for -Binary-Decimal Conversions, at least for magnitudes -between roughly 1.0e\-10 and 1.0e37. -.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 +.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 -.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 -.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. +.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 -.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. +.Ss Exponent Manipulation Functions +.Cl +frexp extract exponent and mantissa +ilogb extract exponent +ldexp multiply by power of 2 +scalbln adjust exponent +scalbn adjust exponent .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. +.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 -.Ed -.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. +.\" .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 (silent) +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 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 +The +.Fn ceil , +.Fn floor , +.Fn llround , +.Fn lround , +.Fn round , and -.Fn pow -.Xc -when it happens to be exact, thanks to fortuitous cancellation of errors. +.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 -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. +.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 -.Sh BUGS -Several functions required by -.St -isoC-99 -are missing, and many functions are not available in their -.Vt "long double" -variants. .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 . +Unlike the algebraic functions listed earlier, the routines +in this section may not produce a result that is correctly rounded. +In general, an unbounded number of digits of a value taken by a +transcendental function may be needed to determine the correctly rounded +result. .Sh SEE ALSO .Xr fenv 3 , .Xr ieee 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 HISTORY A math library with many of the present functions appeared in .At v7 . @@ -488,3 +214,23 @@ 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 +Several functions required by +.St -isoC-99 +are missing, and many functions are not available in their +.Vt "long double" +variants. +.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 . diff --git a/lib/msun/man/sinh.3 b/lib/msun/man/sinh.3 index ce3808cbf001..f7e69955c011 100644 --- a/lib/msun/man/sinh.3 +++ b/lib/msun/man/sinh.3 @@ -31,7 +31,7 @@ .\" .\" from: @(#)sinh.3 6.6 (Berkeley) 4/19/91 .\" $FreeBSD$ -.Dd April 19, 1991 +.Dd January 14, 2005 .Dt SINH 3 .Os .Sh NAME @@ -53,19 +53,6 @@ and the .Fn sinhf functions compute the hyperbolic sine of .Fa x . -.Sh RETURN VALUES -The -.Fn sinh -and the -.Fn sinhf -functions return the hyperbolic sine value unless -the magnitude -of -.Fa x -is too large; in this event, the global variable -.Va errno -is set to -.Er ERANGE . .Sh SEE ALSO .Xr acos 3 , .Xr asin 3 , diff --git a/lib/msun/man/sqrt.3 b/lib/msun/man/sqrt.3 index d4abf01f00a7..99399008f0b5 100644 --- a/lib/msun/man/sqrt.3 +++ b/lib/msun/man/sqrt.3 @@ -80,49 +80,13 @@ and the .Fn sqrtf functions return the requested square root unless an error occurs. -On the -.Tn VAX -or -.Tn Tahoe -processor an attempt to take the +An attempt to take the .Fn sqrt of negative .Fa x -causes an error; in this event, -the global variable -.Va errno -is set to -.Er EDOM -and a reserved operand fault is generated. -.Sh ERROR (due to Roundoff etc.) -The -.Fn cbrt -function -is accurate to within 0.7 -.Em ulps . -.Pp -The -.Fn sqrt -function on a -.Tn VAX -is accurate to within 0.501 -.Em ulps . -Sqrt on a machine that conforms to -.Tn IEEE -754 is correctly rounded -in accordance with the rounding mode in force; the error is less than -half an -.Em ulp -in the default mode (round\-to\-nearest). -An -.Em ulp -is one -.Em U Ns nit -in the -.Em L Ns ast -.Em P Ns lace -carried. +raises an invalid exception and causes an \*(Na to be returned. .Sh SEE ALSO +.Xr fenv 3 , .Xr math 3 .Sh STANDARDS The |
