129bf6af8SDavid Schultz.\" Copyright (c) 1985 Regents of the University of California. 23a8617a8SJordan K. Hubbard.\" All rights reserved. 33a8617a8SJordan K. Hubbard.\" 43a8617a8SJordan K. Hubbard.\" Redistribution and use in source and binary forms, with or without 53a8617a8SJordan K. Hubbard.\" modification, are permitted provided that the following conditions 63a8617a8SJordan K. Hubbard.\" are met: 73a8617a8SJordan K. Hubbard.\" 1. Redistributions of source code must retain the above copyright 83a8617a8SJordan K. Hubbard.\" notice, this list of conditions and the following disclaimer. 93a8617a8SJordan K. Hubbard.\" 2. Redistributions in binary form must reproduce the above copyright 103a8617a8SJordan K. Hubbard.\" notice, this list of conditions and the following disclaimer in the 113a8617a8SJordan K. Hubbard.\" documentation and/or other materials provided with the distribution. 123a8617a8SJordan K. Hubbard.\" 3. All advertising materials mentioning features or use of this software 133a8617a8SJordan K. Hubbard.\" must display the following acknowledgement: 143a8617a8SJordan K. Hubbard.\" This product includes software developed by the University of 153a8617a8SJordan K. Hubbard.\" California, Berkeley and its contributors. 163a8617a8SJordan K. Hubbard.\" 4. Neither the name of the University nor the names of its contributors 173a8617a8SJordan K. Hubbard.\" may be used to endorse or promote products derived from this software 183a8617a8SJordan K. Hubbard.\" without specific prior written permission. 193a8617a8SJordan K. Hubbard.\" 203a8617a8SJordan K. Hubbard.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 213a8617a8SJordan K. Hubbard.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 223a8617a8SJordan K. Hubbard.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 233a8617a8SJordan K. Hubbard.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 243a8617a8SJordan K. Hubbard.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 253a8617a8SJordan K. Hubbard.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 263a8617a8SJordan K. Hubbard.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 273a8617a8SJordan K. Hubbard.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 283a8617a8SJordan K. Hubbard.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 293a8617a8SJordan K. Hubbard.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 303a8617a8SJordan K. Hubbard.\" SUCH DAMAGE. 313a8617a8SJordan K. Hubbard.\" 323a8617a8SJordan K. Hubbard.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91 337f3dea24SPeter Wemm.\" $FreeBSD$ 343a8617a8SJordan K. Hubbard.\" 3529bf6af8SDavid Schultz.Dd January 26, 2005 363a8617a8SJordan K. Hubbard.Dt IEEE 3 373a8617a8SJordan K. Hubbard.Os 383a8617a8SJordan K. Hubbard.Sh NAME 3929bf6af8SDavid Schultz.Nm ieee 4029bf6af8SDavid Schultz.Nd IEEE standard 754 for floating-point arithmetic 413a8617a8SJordan K. Hubbard.Sh DESCRIPTION 4229bf6af8SDavid SchultzThe IEEE Standard 754 for Binary Floating-Point Arithmetic 4329bf6af8SDavid Schultzdefines representations of floating-point numbers and abstract 4429bf6af8SDavid Schultzproperties of arithmetic operations relating to precision, 4529bf6af8SDavid Schultzrounding, and exceptional cases, as described below. 4629bf6af8SDavid Schultz.Ss IEEE STANDARD 754 Floating-Point Arithmetic 4729bf6af8SDavid SchultzRadix: Binary. 483a8617a8SJordan K. Hubbard.Pp 4929bf6af8SDavid SchultzOverflow and underflow: 5029bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 5129bf6af8SDavid SchultzOverflow goes by default to a signed \*(If. 5229bf6af8SDavid SchultzUnderflow is 5329bf6af8SDavid Schultz.Em gradual . 5429bf6af8SDavid Schultz.Ed 553a8617a8SJordan K. Hubbard.Pp 5629bf6af8SDavid SchultzZero is represented ambiguously as +0 or \-0. 5729bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 5829bf6af8SDavid SchultzIts sign transforms correctly through multiplication or 5929bf6af8SDavid Schultzdivision, and is preserved by addition of zeros 6029bf6af8SDavid Schultzwith like signs; but x\-x yields +0 for every 6129bf6af8SDavid Schultzfinite x. 6229bf6af8SDavid SchultzThe only operations that reveal zero's 6329bf6af8SDavid Schultzsign are division by zero and 6429bf6af8SDavid Schultz.Fn copysign x \(+-0 . 6529bf6af8SDavid SchultzIn particular, comparison (x > y, x \(>= y, etc.)\& 6629bf6af8SDavid Schultzcannot be affected by the sign of zero; but if 6729bf6af8SDavid Schultzfinite x = y then \*(If = 1/(x\-y) \(!= \-1/(y\-x) = \-\*(If. 6829bf6af8SDavid Schultz.Ed 693a8617a8SJordan K. Hubbard.Pp 7029bf6af8SDavid SchultzInfinity is signed. 7129bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 7229bf6af8SDavid SchultzIt persists when added to itself 7329bf6af8SDavid Schultzor to any finite number. 7429bf6af8SDavid SchultzIts sign transforms 7529bf6af8SDavid Schultzcorrectly through multiplication and division, and 7629bf6af8SDavid Schultz(finite)/\(+-\*(If\0=\0\(+-0 7729bf6af8SDavid Schultz(nonzero)/0 = \(+-\*(If. 783a8617a8SJordan K. HubbardBut 7929bf6af8SDavid Schultz\*(If\-\*(If, \*(If\(**0 and \*(If/\*(If 8029bf6af8SDavid Schultzare, like 0/0 and sqrt(\-3), 8129bf6af8SDavid Schultzinvalid operations that produce \*(Na. ... 8229bf6af8SDavid Schultz.Ed 833a8617a8SJordan K. Hubbard.Pp 8429bf6af8SDavid SchultzReserved operands (\*(Nas): 8529bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 8629bf6af8SDavid SchultzAn \*(Na is 8729bf6af8SDavid Schultz.Em ( N Ns ot Em a N Ns umber ) . 8829bf6af8SDavid SchultzSome \*(Nas, called Signaling \*(Nas, trap any floating-point operation 8929bf6af8SDavid Schultzperformed upon them; they are used to mark missing 9029bf6af8SDavid Schultzor uninitialized values, or nonexistent elements 9129bf6af8SDavid Schultzof arrays. 9229bf6af8SDavid SchultzThe rest are Quiet \*(Nas; they are 9329bf6af8SDavid Schultzthe default results of Invalid Operations, and 9429bf6af8SDavid Schultzpropagate through subsequent arithmetic operations. 9529bf6af8SDavid SchultzIf x \(!= x then x is \*(Na; every other predicate 9629bf6af8SDavid Schultz(x > y, x = y, x < y, ...) is FALSE if \*(Na is involved. 9729bf6af8SDavid Schultz.Ed 9829bf6af8SDavid Schultz.Pp 9929bf6af8SDavid SchultzRounding: 10029bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 10129bf6af8SDavid SchultzEvery algebraic operation (+, \-, \(**, /, 10229bf6af8SDavid Schultz\(sr) 10329bf6af8SDavid Schultzis rounded by default to within half an 10429bf6af8SDavid Schultz.Em ulp , 10529bf6af8SDavid Schultzand when the rounding error is exactly half an 10629bf6af8SDavid Schultz.Em ulp 10729bf6af8SDavid Schultzthen 10829bf6af8SDavid Schultzthe rounded value's least significant bit is zero. 10929bf6af8SDavid Schultz(An 11029bf6af8SDavid Schultz.Em ulp 11129bf6af8SDavid Schultzis one 11229bf6af8SDavid Schultz.Em U Ns nit 11329bf6af8SDavid Schultzin the 11429bf6af8SDavid Schultz.Em L Ns ast 11529bf6af8SDavid Schultz.Em P Ns lace . ) 11629bf6af8SDavid SchultzThis kind of rounding is usually the best kind, 11729bf6af8SDavid Schultzsometimes provably so; for instance, for every 11829bf6af8SDavid Schultzx = 1.0, 2.0, 3.0, 4.0, ..., 2.0**52, we find 11929bf6af8SDavid Schultz(x/3.0)\(**3.0 == x and (x/10.0)\(**10.0 == x and ... 12029bf6af8SDavid Schultzdespite that both the quotients and the products 12129bf6af8SDavid Schultzhave been rounded. 12229bf6af8SDavid SchultzOnly rounding like IEEE 754 can do that. 12329bf6af8SDavid SchultzBut no single kind of rounding can be 12429bf6af8SDavid Schultzproved best for every circumstance, so IEEE 754 12529bf6af8SDavid Schultzprovides rounding towards zero or towards 12629bf6af8SDavid Schultz+\*(If or towards \-\*(If 12729bf6af8SDavid Schultzat the programmer's option. 12829bf6af8SDavid Schultz.Ed 12929bf6af8SDavid Schultz.Pp 13029bf6af8SDavid SchultzExceptions: 13129bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 13229bf6af8SDavid SchultzIEEE 754 recognizes five kinds of floating-point exceptions, 13329bf6af8SDavid Schultzlisted below in declining order of probable importance. 13429bf6af8SDavid Schultz.Bl -column -offset indent "Invalid Operation" "Gradual Underflow" 13529bf6af8SDavid Schultz.Em "Exception Default Result" 13629bf6af8SDavid SchultzInvalid Operation \*(Na, or FALSE 13729bf6af8SDavid SchultzOverflow \(+-\*(If 13829bf6af8SDavid SchultzDivide by Zero \(+-\*(If 13929bf6af8SDavid SchultzUnderflow Gradual Underflow 14029bf6af8SDavid SchultzInexact Rounded value 14129bf6af8SDavid Schultz.El 14229bf6af8SDavid Schultz.Pp 14329bf6af8SDavid SchultzNOTE: An Exception is not an Error unless handled 14429bf6af8SDavid Schultzbadly. 14529bf6af8SDavid SchultzWhat makes a class of exceptions exceptional 14629bf6af8SDavid Schultzis that no single default response can be satisfactory 14729bf6af8SDavid Schultzin every instance. 14829bf6af8SDavid SchultzOn the other hand, if a default 14929bf6af8SDavid Schultzresponse will serve most instances satisfactorily, 15029bf6af8SDavid Schultzthe unsatisfactory instances cannot justify aborting 15129bf6af8SDavid Schultzcomputation every time the exception occurs. 15229bf6af8SDavid Schultz.Ed 15329bf6af8SDavid Schultz.Ss Data Formats 15429bf6af8SDavid SchultzSingle-precision: 15529bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 15629bf6af8SDavid SchultzType name: 15729bf6af8SDavid Schultz.Vt float 15829bf6af8SDavid Schultz.Pp 15929bf6af8SDavid SchultzWordsize: 32 bits. 16029bf6af8SDavid Schultz.Pp 16129bf6af8SDavid SchultzPrecision: 24 significant bits, 16229bf6af8SDavid Schultzroughly like 7 significant decimals. 16329bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 16429bf6af8SDavid SchultzIf x and x' are consecutive positive single-precision 16529bf6af8SDavid Schultznumbers (they differ by 1 16629bf6af8SDavid Schultz.Em ulp ) , 16729bf6af8SDavid Schultzthen 16829bf6af8SDavid Schultz.Bd -ragged -compact 16929bf6af8SDavid Schultz5.9e\-08 < 0.5**24 < (x'\-x)/x \(<= 0.5**23 < 1.2e\-07. 17029bf6af8SDavid Schultz.Ed 17129bf6af8SDavid Schultz.Ed 17229bf6af8SDavid Schultz.Pp 17329bf6af8SDavid Schultz.Bl -column "XXX" -compact 17429bf6af8SDavid SchultzRange: Overflow threshold = 2.0**128 = 3.4e38 17529bf6af8SDavid Schultz Underflow threshold = 0.5**126 = 1.2e\-38 17629bf6af8SDavid Schultz.El 17729bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 17829bf6af8SDavid SchultzUnderflowed results round to the nearest 17929bf6af8SDavid Schultzinteger multiple of 0.5**149 = 1.4e\-45. 18029bf6af8SDavid Schultz.Ed 18129bf6af8SDavid Schultz.Ed 18229bf6af8SDavid Schultz.Pp 18329bf6af8SDavid SchultzDouble-precision: 18429bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 18529bf6af8SDavid SchultzType name: 18629bf6af8SDavid Schultz.Vt double 18729bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 18829bf6af8SDavid SchultzOn some architectures, 18929bf6af8SDavid Schultz.Vt long double 19029bf6af8SDavid Schultzis the the same as 19129bf6af8SDavid Schultz.Vt double . 19229bf6af8SDavid Schultz.Ed 19329bf6af8SDavid Schultz.Pp 19429bf6af8SDavid SchultzWordsize: 64 bits. 19529bf6af8SDavid Schultz.Pp 19629bf6af8SDavid SchultzPrecision: 53 significant bits, 19729bf6af8SDavid Schultzroughly like 16 significant decimals. 19829bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 19929bf6af8SDavid SchultzIf x and x' are consecutive positive double-precision 20029bf6af8SDavid Schultznumbers (they differ by 1 20129bf6af8SDavid Schultz.Em ulp ) , 20229bf6af8SDavid Schultzthen 20329bf6af8SDavid Schultz.Bd -ragged -compact 20429bf6af8SDavid Schultz1.1e\-16 < 0.5**53 < (x'\-x)/x \(<= 0.5**52 < 2.3e\-16. 20529bf6af8SDavid Schultz.Ed 20629bf6af8SDavid Schultz.Ed 20729bf6af8SDavid Schultz.Pp 20829bf6af8SDavid Schultz.Bl -column "XXX" -compact 20929bf6af8SDavid SchultzRange: Overflow threshold = 2.0**1024 = 1.8e308 21029bf6af8SDavid Schultz Underflow threshold = 0.5**1022 = 2.2e\-308 21129bf6af8SDavid Schultz.El 21229bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 21329bf6af8SDavid SchultzUnderflowed results round to the nearest 21429bf6af8SDavid Schultzinteger multiple of 0.5**1074 = 4.9e\-324. 21529bf6af8SDavid Schultz.Ed 21629bf6af8SDavid Schultz.Ed 21729bf6af8SDavid Schultz.Pp 21829bf6af8SDavid SchultzExtended-precision: 21929bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 22029bf6af8SDavid SchultzType name: 22129bf6af8SDavid Schultz.Vt long double 22229bf6af8SDavid Schultz(when supported by the hardware) 22329bf6af8SDavid Schultz.Pp 22429bf6af8SDavid SchultzWordsize: 96 bits. 22529bf6af8SDavid Schultz.Pp 22629bf6af8SDavid SchultzPrecision: 64 significant bits, 22729bf6af8SDavid Schultzroughly like 19 significant decimals. 22829bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 22993e06638SDavid SchultzIf x and x' are consecutive positive extended-precision 23029bf6af8SDavid Schultznumbers (they differ by 1 23129bf6af8SDavid Schultz.Em ulp ) , 23229bf6af8SDavid Schultzthen 23329bf6af8SDavid Schultz.Bd -ragged -compact 23429bf6af8SDavid Schultz1.0e\-19 < 0.5**63 < (x'\-x)/x \(<= 0.5**62 < 2.2e\-19. 23529bf6af8SDavid Schultz.Ed 23629bf6af8SDavid Schultz.Ed 23729bf6af8SDavid Schultz.Pp 23829bf6af8SDavid Schultz.Bl -column "XXX" -compact 23929bf6af8SDavid SchultzRange: Overflow threshold = 2.0**16384 = 1.2e4932 24029bf6af8SDavid Schultz Underflow threshold = 0.5**16382 = 3.4e\-4932 24129bf6af8SDavid Schultz.El 24229bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 24329bf6af8SDavid SchultzUnderflowed results round to the nearest 2441b32579fSDavid Schultzinteger multiple of 0.5**16445 = 5.7e\-4953. 24529bf6af8SDavid Schultz.Ed 24629bf6af8SDavid Schultz.Ed 24729bf6af8SDavid Schultz.Pp 24829bf6af8SDavid SchultzQuad-extended-precision: 24929bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 25029bf6af8SDavid SchultzType name: 25129bf6af8SDavid Schultz.Vt long double 25229bf6af8SDavid Schultz(when supported by the hardware) 25329bf6af8SDavid Schultz.Pp 25429bf6af8SDavid SchultzWordsize: 128 bits. 25529bf6af8SDavid Schultz.Pp 25629bf6af8SDavid SchultzPrecision: 113 significant bits, 25729bf6af8SDavid Schultzroughly like 34 significant decimals. 25829bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 25993e06638SDavid SchultzIf x and x' are consecutive positive quad-extended-precision 26029bf6af8SDavid Schultznumbers (they differ by 1 26129bf6af8SDavid Schultz.Em ulp ) , 26229bf6af8SDavid Schultzthen 26329bf6af8SDavid Schultz.Bd -ragged -compact 26429bf6af8SDavid Schultz9.6e\-35 < 0.5**113 < (x'\-x)/x \(<= 0.5**112 < 2.0e\-34. 26529bf6af8SDavid Schultz.Ed 26629bf6af8SDavid Schultz.Ed 26729bf6af8SDavid Schultz.Pp 26829bf6af8SDavid Schultz.Bl -column "XXX" -compact 26929bf6af8SDavid SchultzRange: Overflow threshold = 2.0**16384 = 1.2e4932 27029bf6af8SDavid Schultz Underflow threshold = 0.5**16382 = 3.4e\-4932 27129bf6af8SDavid Schultz.El 27229bf6af8SDavid Schultz.Bd -ragged -offset indent -compact 27329bf6af8SDavid SchultzUnderflowed results round to the nearest 27429bf6af8SDavid Schultzinteger multiple of 0.5**16494 = 6.5e\-4966. 27529bf6af8SDavid Schultz.Ed 27629bf6af8SDavid Schultz.Ed 27729bf6af8SDavid Schultz.Ss Additional Information Regarding Exceptions 27829bf6af8SDavid Schultz.Pp 27929bf6af8SDavid SchultzFor each kind of floating-point exception, IEEE 754 28029bf6af8SDavid Schultzprovides a Flag that is raised each time its exception 28129bf6af8SDavid Schultzis signaled, and stays raised until the program resets 28229bf6af8SDavid Schultzit. 28329bf6af8SDavid SchultzPrograms may also test, save and restore a flag. 28429bf6af8SDavid SchultzThus, IEEE 754 provides three ways by which programs 28529bf6af8SDavid Schultzmay cope with exceptions for which the default result 28629bf6af8SDavid Schultzmight be unsatisfactory: 28729bf6af8SDavid Schultz.Bl -enum 28829bf6af8SDavid Schultz.It 28929bf6af8SDavid SchultzTest for a condition that might cause an exception 29029bf6af8SDavid Schultzlater, and branch to avoid the exception. 29129bf6af8SDavid Schultz.It 29229bf6af8SDavid SchultzTest a flag to see whether an exception has occurred 29329bf6af8SDavid Schultzsince the program last reset its flag. 29429bf6af8SDavid Schultz.It 29529bf6af8SDavid SchultzTest a result to see whether it is a value that only 29629bf6af8SDavid Schultzan exception could have produced. 29729bf6af8SDavid Schultz.Pp 29829bf6af8SDavid SchultzCAUTION: The only reliable ways to discover 29929bf6af8SDavid Schultzwhether Underflow has occurred are to test whether 30029bf6af8SDavid Schultzproducts or quotients lie closer to zero than the 30129bf6af8SDavid Schultzunderflow threshold, or to test the Underflow 30229bf6af8SDavid Schultzflag. 30329bf6af8SDavid Schultz(Sums and differences cannot underflow in 30429bf6af8SDavid SchultzIEEE 754; if x \(!= y then x\-y is correct to 30529bf6af8SDavid Schultzfull precision and certainly nonzero regardless of 30629bf6af8SDavid Schultzhow tiny it may be.) 30729bf6af8SDavid SchultzProducts and quotients that 30829bf6af8SDavid Schultzunderflow gradually can lose accuracy gradually 30929bf6af8SDavid Schultzwithout vanishing, so comparing them with zero 31029bf6af8SDavid Schultz(as one might on a VAX) will not reveal the loss. 31129bf6af8SDavid SchultzFortunately, if a gradually underflowed value is 31229bf6af8SDavid Schultzdestined to be added to something bigger than the 31329bf6af8SDavid Schultzunderflow threshold, as is almost always the case, 31429bf6af8SDavid Schultzdigits lost to gradual underflow will not be missed 31529bf6af8SDavid Schultzbecause they would have been rounded off anyway. 31629bf6af8SDavid SchultzSo gradual underflows are usually 31729bf6af8SDavid Schultz.Em provably 31829bf6af8SDavid Schultzignorable. 31929bf6af8SDavid SchultzThe same cannot be said of underflows flushed to 0. 32029bf6af8SDavid Schultz.El 32129bf6af8SDavid Schultz.Pp 32229bf6af8SDavid SchultzAt the option of an implementor conforming to IEEE 754, 32329bf6af8SDavid Schultzother ways to cope with exceptions may be provided: 32429bf6af8SDavid Schultz.Bl -enum 32529bf6af8SDavid Schultz.It 32629bf6af8SDavid SchultzABORT. 32729bf6af8SDavid SchultzThis mechanism classifies an exception in 32829bf6af8SDavid Schultzadvance as an incident to be handled by means 32929bf6af8SDavid Schultztraditionally associated with error-handling 33029bf6af8SDavid Schultzstatements like "ON ERROR GO TO ...". 33129bf6af8SDavid SchultzDifferent 33229bf6af8SDavid Schultzlanguages offer different forms of this statement, 33329bf6af8SDavid Schultzbut most share the following characteristics: 33429bf6af8SDavid Schultz.Bl -dash 33529bf6af8SDavid Schultz.It 33629bf6af8SDavid SchultzNo means is provided to substitute a value for 33729bf6af8SDavid Schultzthe offending operation's result and resume 33829bf6af8SDavid Schultzcomputation from what may be the middle of an 33929bf6af8SDavid Schultzexpression. 34029bf6af8SDavid SchultzAn exceptional result is abandoned. 34129bf6af8SDavid Schultz.It 34229bf6af8SDavid SchultzIn a subprogram that lacks an error-handling 34329bf6af8SDavid Schultzstatement, an exception causes the subprogram to 34429bf6af8SDavid Schultzabort within whatever program called it, and so 34529bf6af8SDavid Schultzon back up the chain of calling subprograms until 34629bf6af8SDavid Schultzan error-handling statement is encountered or the 34729bf6af8SDavid Schultzwhole task is aborted and memory is dumped. 34829bf6af8SDavid Schultz.El 34929bf6af8SDavid Schultz.It 35029bf6af8SDavid SchultzSTOP. 35129bf6af8SDavid SchultzThis mechanism, requiring an interactive 35229bf6af8SDavid Schultzdebugging environment, is more for the programmer 35329bf6af8SDavid Schultzthan the program. 35429bf6af8SDavid SchultzIt classifies an exception in 35529bf6af8SDavid Schultzadvance as a symptom of a programmer's error; the 35629bf6af8SDavid Schultzexception suspends execution as near as it can to 35729bf6af8SDavid Schultzthe offending operation so that the programmer can 35829bf6af8SDavid Schultzlook around to see how it happened. 35929bf6af8SDavid SchultzQuite often 36029bf6af8SDavid Schultzthe first several exceptions turn out to be quite 36129bf6af8SDavid Schultzunexceptionable, so the programmer ought ideally 36229bf6af8SDavid Schultzto be able to resume execution after each one as if 36329bf6af8SDavid Schultzexecution had not been stopped. 36429bf6af8SDavid Schultz.It 36529bf6af8SDavid Schultz\&... Other ways lie beyond the scope of this document. 36629bf6af8SDavid Schultz.El 36729bf6af8SDavid Schultz.Pp 36829bf6af8SDavid SchultzIdeally, each 36929bf6af8SDavid Schultzelementary function should act as if it were indivisible, or 37029bf6af8SDavid Schultzatomic, in the sense that ... 37129bf6af8SDavid Schultz.Bl -enum 37229bf6af8SDavid Schultz.It 37329bf6af8SDavid SchultzNo exception should be signaled that is not deserved by 37429bf6af8SDavid Schultzthe data supplied to that function. 37529bf6af8SDavid Schultz.It 37629bf6af8SDavid SchultzAny exception signaled should be identified with that 37729bf6af8SDavid Schultzfunction rather than with one of its subroutines. 37829bf6af8SDavid Schultz.It 37929bf6af8SDavid SchultzThe internal behavior of an atomic function should not 38029bf6af8SDavid Schultzbe disrupted when a calling program changes from 38129bf6af8SDavid Schultzone to another of the five or so ways of handling 38229bf6af8SDavid Schultzexceptions listed above, although the definition 38329bf6af8SDavid Schultzof the function may be correlated intentionally 38429bf6af8SDavid Schultzwith exception handling. 38529bf6af8SDavid Schultz.El 38629bf6af8SDavid Schultz.Pp 38729bf6af8SDavid SchultzThe functions in 38829bf6af8SDavid Schultz.Nm libm 38929bf6af8SDavid Schultzare only approximately atomic. 39029bf6af8SDavid SchultzThey signal no inappropriate exception except possibly ... 39129bf6af8SDavid Schultz.Bl -tag -width indent -offset indent -compact 39229bf6af8SDavid Schultz.It Xo 39329bf6af8SDavid SchultzOver/Underflow 39429bf6af8SDavid Schultz.Xc 39529bf6af8SDavid Schultzwhen a result, if properly computed, might have lain barely within range, and 39629bf6af8SDavid Schultz.It Xo 39729bf6af8SDavid SchultzInexact in 39829bf6af8SDavid Schultz.Fn cabs , 39929bf6af8SDavid Schultz.Fn cbrt , 40029bf6af8SDavid Schultz.Fn hypot , 40129bf6af8SDavid Schultz.Fn log10 4027a15a32aSJordan K. Hubbardand 40329bf6af8SDavid Schultz.Fn pow 40429bf6af8SDavid Schultz.Xc 40529bf6af8SDavid Schultzwhen it happens to be exact, thanks to fortuitous cancellation of errors. 40629bf6af8SDavid Schultz.El 40729bf6af8SDavid SchultzOtherwise, ... 40829bf6af8SDavid Schultz.Bl -tag -width indent -offset indent -compact 40929bf6af8SDavid Schultz.It Xo 41029bf6af8SDavid SchultzInvalid Operation is signaled only when 41129bf6af8SDavid Schultz.Xc 41229bf6af8SDavid Schultzany result but \*(Na would probably be misleading. 41329bf6af8SDavid Schultz.It Xo 41429bf6af8SDavid SchultzOverflow is signaled only when 41529bf6af8SDavid Schultz.Xc 41629bf6af8SDavid Schultzthe exact result would be finite but beyond the overflow threshold. 41729bf6af8SDavid Schultz.It Xo 41829bf6af8SDavid SchultzDivide-by-Zero is signaled only when 41929bf6af8SDavid Schultz.Xc 42029bf6af8SDavid Schultza function takes exactly infinite values at finite operands. 42129bf6af8SDavid Schultz.It Xo 42229bf6af8SDavid SchultzUnderflow is signaled only when 42329bf6af8SDavid Schultz.Xc 42429bf6af8SDavid Schultzthe exact result would be nonzero but tinier than the underflow threshold. 42529bf6af8SDavid Schultz.It Xo 42629bf6af8SDavid SchultzInexact is signaled only when 42729bf6af8SDavid Schultz.Xc 42829bf6af8SDavid Schultzgreater range or precision would be needed to represent the exact result. 42929bf6af8SDavid Schultz.El 4303a8617a8SJordan K. Hubbard.Sh SEE ALSO 43129bf6af8SDavid Schultz.Xr fenv 3 , 43229bf6af8SDavid Schultz.Xr ieee_test 3 , 4333a8617a8SJordan K. Hubbard.Xr math 3 43429bf6af8SDavid Schultz.Pp 43529bf6af8SDavid SchultzAn explanation of IEEE 754 and its proposed extension p854 43629bf6af8SDavid Schultzwas published in the IEEE magazine MICRO in August 1984 under 43729bf6af8SDavid Schultzthe title "A Proposed Radix- and Word-length-independent 43829bf6af8SDavid SchultzStandard for Floating-point Arithmetic" by 43929bf6af8SDavid Schultz.An "W. J. Cody" 44029bf6af8SDavid Schultzet al. 44129bf6af8SDavid SchultzThe manuals for Pascal, C and BASIC on the Apple Macintosh 44229bf6af8SDavid Schultzdocument the features of IEEE 754 pretty well. 44329bf6af8SDavid SchultzArticles in the IEEE magazine COMPUTER vol.\& 14 no.\& 3 (Mar.\& 44429bf6af8SDavid Schultz1981), and in the ACM SIGNUM Newsletter Special Issue of 44529bf6af8SDavid SchultzOct.\& 1979, may be helpful although they pertain to 44629bf6af8SDavid Schultzsuperseded drafts of the standard. 44724a0682cSRuslan Ermilov.Sh STANDARDS 44824a0682cSRuslan Ermilov.St -ieee754 449