summaryrefslogtreecommitdiff
path: root/lib/libm
diff options
context:
space:
mode:
authorwiz <wiz@NetBSD.org>2002-10-01 19:21:30 +0000
committerwiz <wiz@NetBSD.org>2002-10-01 19:21:30 +0000
commit71dd1ccd73d89d851ae2886ef6281ef9004ea148 (patch)
treeee528cd9e01b77884e0e34fe64c7e281e234b8f9 /lib/libm
parentad2758f3753710bdbc553e9eb8b4bbbbc69114b1 (diff)
New sentence, new line. From Robert Elz.
Diffstat (limited to 'lib/libm')
-rw-r--r--lib/libm/man/atan2.36
-rw-r--r--lib/libm/man/exp.38
-rw-r--r--lib/libm/man/hypot.35
-rw-r--r--lib/libm/man/ieee.36
-rw-r--r--lib/libm/man/math.3117
5 files changed, 81 insertions, 61 deletions
diff --git a/lib/libm/man/atan2.3 b/lib/libm/man/atan2.3
index 38b4b6d2ad5..1d0bcfed14f 100644
--- a/lib/libm/man/atan2.3
+++ b/lib/libm/man/atan2.3
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)atan2.3 5.1 (Berkeley) 5/2/91
-.\" $NetBSD: atan2.3,v 1.13 2002/02/20 11:53:02 wiz Exp $
+.\" $NetBSD: atan2.3,v 1.14 2002/10/01 19:21:30 wiz Exp $
.\"
.Dd May 2, 1991
.Dt ATAN2 3
@@ -143,8 +143,8 @@ is mapped to
(r=0,theta=0)
.if t \
(r=0,\(*h=0)
-on a VAX. In general, conversions to polar coordinates
-should be computed thus:
+on a VAX.
+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)
diff --git a/lib/libm/man/exp.3 b/lib/libm/man/exp.3
index 80d99c7d295..ace180e54d3 100644
--- a/lib/libm/man/exp.3
+++ b/lib/libm/man/exp.3
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)exp.3 6.12 (Berkeley) 7/31/91
-.\" $NetBSD: exp.3,v 1.18 2002/02/20 11:51:15 wiz Exp $
+.\" $NetBSD: exp.3,v 1.19 2002/10/01 19:21:30 wiz Exp $
.\"
.Dd July 31, 1991
.Dt EXP 3
@@ -235,12 +235,14 @@ operand on a
.Tn VAX ) .
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:
+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
+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.
diff --git a/lib/libm/man/hypot.3 b/lib/libm/man/hypot.3
index 883dc803ee2..03aff99dd27 100644
--- a/lib/libm/man/hypot.3
+++ b/lib/libm/man/hypot.3
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)hypot.3 6.7 (Berkeley) 5/6/91
-.\" $NetBSD: hypot.3,v 1.11 2002/02/20 11:51:43 wiz Exp $
+.\" $NetBSD: hypot.3,v 1.12 2002/10/01 19:21:30 wiz Exp $
.\"
.Dd May 6, 1991
.Dt HYPOT 3
@@ -136,4 +136,5 @@ The
and
.Fn cabsf
functions use structures that are not defined in any header and need to
-be defined by the user. As such they cannot be prototyped properly.
+be defined by the user.
+As such they cannot be prototyped properly.
diff --git a/lib/libm/man/ieee.3 b/lib/libm/man/ieee.3
index b10eaa31d7b..d500985fc49 100644
--- a/lib/libm/man/ieee.3
+++ b/lib/libm/man/ieee.3
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
-.\" $NetBSD: ieee.3,v 1.15 2002/02/20 11:52:13 wiz Exp $
+.\" $NetBSD: ieee.3,v 1.16 2002/10/01 19:21:30 wiz Exp $
.\"
.Dd February 25, 1994
.Dt IEEE 3
@@ -142,8 +142,8 @@ moreover if
1/2
then
.Fa n
-is even. Consequently
-the remainder is computed exactly and
+is even.
+Consequently the remainder is computed exactly and
.Sm off
.Pf \\*(Ba Fa r No \\*(Ba
.Sm on
diff --git a/lib/libm/man/math.3 b/lib/libm/man/math.3
index 6ba04daf220..52314f04c58 100644
--- a/lib/libm/man/math.3
+++ b/lib/libm/man/math.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: math.3,v 1.12 2002/02/08 01:28:24 ross Exp $
+.\" $NetBSD: math.3,v 1.13 2002/10/01 19:21:30 wiz Exp $
.\"
.\" Copyright (c) 1985 Regents of the University of California.
.\" All rights reserved.
@@ -112,12 +112,14 @@ in late 1985, most of the foregoing functions come in two
versions, one for the double\-precision "D" format in the
DEC VAX\-11 family of computers, another for double\-precision
arithmetic conforming to the IEEE Standard 754 for Binary
-Floating\-Point Arithmetic. The two versions behave very
+Floating\-Point Arithmetic.
+The two versions behave very
similarly, as should be expected from programs more accurate
-and robust than was the norm when UNIX was born. For
-instance, the programs are accurate to within the numbers
+and robust than was the norm when UNIX was born.
+For instance, the programs are accurate to within the numbers
of \*(ups tabulated above; an \*(up is one \fIU\fRnit in the \fIL\fRast
-\fIP\fRlace. And the programs have been cured of anomalies that
+\fIP\fRlace.
+And the programs have been cured of anomalies that
afflicted the older math library \fIlibm\fR in which incidents like
the following had been reported:
.RS
@@ -142,16 +144,19 @@ explained, to which end the following notes are provided.
\fBDEC VAX\-11 D_floating\-point:\fR
.PP
This is the format for which the original math library \fIlibm\fR
-was developed, and to which this manual is still principally
-dedicated. It is \fIthe\fR double\-precision format for the PDP\-11
+was developed, and to which this manual is still principally dedicated.
+It is \fIthe\fR double\-precision format for the PDP\-11
and the earlier VAX\-11 machines; VAX\-11s after 1983 were
provided with an optional "G" format closer to the IEEE
-double\-precision format. The earlier DEC MicroVAXs have no
-D format, only G double\-precision. (Why? Why not?)
+double\-precision format.
+The earlier DEC MicroVAXs have no D format, only G double\-precision.
+(Why?
+Why not?)
.PP
Properties of D_floating\-point:
.RS
-Wordsize: 64 bits, 8 bytes. Radix: Binary.
+Wordsize: 64 bits, 8 bytes.
+Radix: Binary.
.br
Precision: 56
.if n \
@@ -190,8 +195,8 @@ It is possible to have x
.if t \
\(!=
y and yet
-x\-y = 0 because of underflow. Similarly
-x \*[Gt] y \*[Gt] 0 cannot prevent either x\(**y = 0
+x\-y = 0 because of underflow.
+Similarly x \*[Gt] y \*[Gt] 0 cannot prevent either x\(**y = 0
or y/x = 0 from happening without warning.
.RE
.RE
@@ -262,8 +267,8 @@ speed and accuracy; the \fIlibm\fR codes use tricky formulas
compact enough that all of them may some day fit into a ROM.
.PP
More important, DEC regards the VMS codes as proprietary
-and guards them zealously against unauthorized use. But the
-\fIlibm\fR codes in 4.3 BSD are intended for the public domain;
+and guards them zealously against unauthorized use.
+But the \fIlibm\fR codes in 4.3 BSD are intended for the public domain;
they may be copied freely provided their provenance is always
acknowledged, and provided users assist the authors in their
researches by reporting experience with the codes.
@@ -297,7 +302,8 @@ nobody has volunteered to do that yet.
.PP
The codes in 4.3 BSD's \fIlibm\fR for machines that conform to
IEEE 754 are intended primarily for the National Semi. 32081
-and WTL 1164/65. To use these codes with the Intel or Zilog
+and WTL 1164/65.
+To use these codes with the Intel or Zilog
chips, or with the Apple Macintosh or ELXSI 6400, is to
forego the use of better codes provided (perhaps freely) by
those companies and designed by some of the authors of the
@@ -323,7 +329,8 @@ IEEE 754 need use anything worse than the new \fIlibm\fR.
.PP
Properties of IEEE 754 Double\-Precision:
.RS
-Wordsize: 64 bits, 8 bytes. Radix: Binary.
+Wordsize: 64 bits, 8 bytes.
+Radix: Binary.
.br
Precision: 53
.if n \
@@ -360,7 +367,8 @@ Zero is represented ambiguously as +0 or \-0.
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
+finite x.
+The only operations that reveal zero's
sign are division by zero and copysign(x,\(+-0).
In particular, comparison (x \*[Gt] y, x \*[Ge] y, etc.)
cannot be affected by the sign of zero; but if
@@ -378,7 +386,8 @@ finite x = y then
is signed.
.RS
it persists when added to itself
-or to any finite number. Its sign transforms
+or to any finite number.
+Its sign transforms
correctly through multiplication and division, and
.If (finite)/\(+- \0=\0\(+-0
(nonzero)/0 =
@@ -397,8 +406,8 @@ there are 2**53\-2 of them, all
called \*(nn (\fIN\fRot \fIa N\fRumber).
Some, called Signaling \*(nns, 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 \*(nns; they are
+or uninitialized values, or nonexistent elements of arrays.
+The rest are Quiet \*(nns; they are
the default results of Invalid Operations, and
propagate through subsequent arithmetic operations.
If x
@@ -431,15 +440,16 @@ 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
+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
+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.
.RE
@@ -466,10 +476,11 @@ Inexact Rounded value
.ta
.fi
.RE
-NOTE: An Exception is not an Error unless handled
-badly. What makes a class of exceptions exceptional
+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
+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.
@@ -477,8 +488,8 @@ computation every time the exception occurs.
.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.
+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:
@@ -495,8 +506,8 @@ an exception could have produced.
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
+underflow threshold, or to test the Underflow flag.
+(Sums and differences cannot underflow in
IEEE 754; if x
.if n \
!=
@@ -504,7 +515,8 @@ 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
+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.
@@ -520,17 +532,18 @@ The same cannot be said of underflows flushed to 0.
At the option of an implementor conforming to IEEE 754,
other ways to cope with exceptions may be provided:
.IP 4) \w'\0\0\0\0'u
-ABORT. This mechanism classifies an exception in
+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,
+statements like "ON ERROR GO TO ...".
+Different languages offer different forms of this statement,
but most share the following characteristics:
.IP \(em \w'\0\0\0\0'u
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.
+computation from what may be the middle of an expression.
+An exceptional result is abandoned.
.IP \(em \w'\0\0\0\0'u
In a subprogram that lacks an error\-handling
statement, an exception causes the subprogram to
@@ -539,13 +552,16 @@ 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.
.IP 5) \w'\0\0\0\0'u
-STOP. This mechanism, requiring an interactive
+STOP.
+This mechanism, requiring an interactive
debugging environment, is more for the programmer
-than the program. It classifies an exception in
+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
+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
@@ -557,9 +573,9 @@ execution had not been stopped.
The crucial problem for exception handling is the problem of
Scope, and the problem's solution is understood, but not
enough manpower was available to implement it fully in time
-to be distributed in 4.3 BSD's \fIlibm\fR. Ideally, each
-elementary function should act as if it were indivisible, or
-atomic, in the sense that ...
+to be distributed in 4.3 BSD's \fIlibm\fR.
+Ideally, each elementary function should act
+as if it were indivisible, or atomic, in the sense that ...
.IP i) \w'iii)'u+2n
No exception should be signaled that is not deserved by
the data supplied to that function.
@@ -576,14 +592,14 @@ with exception handling.
.PP
Ideally, every programmer should be able \fIconveniently\fR to
turn a debugged subprogram into one that appears atomic to
-its users. But simulating all three characteristics of an
+its users.
+But simulating all three characteristics of an
atomic function is still a tedious affair, entailing hosts
of tests and saves\-restores; work is under way to ameliorate
the inconvenience.
.PP
-Meanwhile, the functions in \fIlibm\fR are only approximately
-atomic. They signal no inappropriate exception except
-possibly ...
+Meanwhile, the functions in \fIlibm\fR are only approximately atomic.
+They signal no inappropriate exception except possibly ...
.RS
Over/Underflow
.RS
@@ -633,15 +649,16 @@ the title "A Proposed Radix\- and Word\-length\-independent
Standard for Floating\-point Arithmetic" by 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
+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 BUGS
When signals are appropriate, they are emitted by certain
operations within the codes, so a subroutine\-trace may be
needed to identify the function with its signal in case
-method 5) above is in use. And the codes all take the
+method 5) above is in use.
+And the codes all take the
IEEE 754 defaults for granted; this means that a decision to
trap all divisions by zero could disrupt a code that would
otherwise get correct results despite division by zero.