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