1*05a0b428SJohn Marino.\" $OpenBSD: feclearexcept.3,v 1.4 2013/06/05 03:40:26 tedu Exp $ 2*05a0b428SJohn Marino.\" 3*05a0b428SJohn Marino.\" Copyright (c) 2011 Martynas Venckus <martynas@openbsd.org> 4*05a0b428SJohn Marino.\" 5*05a0b428SJohn Marino.\" Permission to use, copy, modify, and distribute this software for any 6*05a0b428SJohn Marino.\" purpose with or without fee is hereby granted, provided that the above 7*05a0b428SJohn Marino.\" copyright notice and this permission notice appear in all copies. 8*05a0b428SJohn Marino.\" 9*05a0b428SJohn Marino.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10*05a0b428SJohn Marino.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11*05a0b428SJohn Marino.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12*05a0b428SJohn Marino.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13*05a0b428SJohn Marino.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14*05a0b428SJohn Marino.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15*05a0b428SJohn Marino.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16*05a0b428SJohn Marino.\" 17*05a0b428SJohn Marino.Dd $Mdocdate: June 5 2013 $ 18*05a0b428SJohn Marino.Dt FECLEAREXCEPT 3 19*05a0b428SJohn Marino.Os 20*05a0b428SJohn Marino.Sh NAME 21*05a0b428SJohn Marino.Nm feclearexcept , 22*05a0b428SJohn Marino.Nm fegetexceptflag , 23*05a0b428SJohn Marino.Nm feraiseexcept , 24*05a0b428SJohn Marino.Nm fesetexceptflag , 25*05a0b428SJohn Marino.Nm fetestexcept 26*05a0b428SJohn Marino.Nd access floating-point status flags 27*05a0b428SJohn Marino.Sh SYNOPSIS 28*05a0b428SJohn Marino.In fenv.h 29*05a0b428SJohn Marino.Ft int 30*05a0b428SJohn Marino.Fn feclearexcept "int excepts" 31*05a0b428SJohn Marino.Ft int 32*05a0b428SJohn Marino.Fn fegetexceptflag "fexcept_t *flagp" "int excepts" 33*05a0b428SJohn Marino.Ft int 34*05a0b428SJohn Marino.Fn feraiseexcept "int excepts" 35*05a0b428SJohn Marino.Ft int 36*05a0b428SJohn Marino.Fn fesetexceptflag "const fexcept_t *flagp" "int excepts" 37*05a0b428SJohn Marino.Ft int 38*05a0b428SJohn Marino.Fn fetestexcept "int excepts" 39*05a0b428SJohn Marino.Sh DESCRIPTION 40*05a0b428SJohn MarinoThese functions provide access to the floating-point status flags. 41*05a0b428SJohn MarinoThe 42*05a0b428SJohn Marino.Fa excepts 43*05a0b428SJohn Marinoinput argument is a bitmask specifying an exception type and 44*05a0b428SJohn Marinocontaining any of the values listed below. 45*05a0b428SJohn Marino.Bl -tag -width ".Dv FE_DIVBYZERO" 46*05a0b428SJohn Marino.It Dv FE_DIVBYZERO 47*05a0b428SJohn MarinoA divide-by-zero exception occurs when the program attempts to 48*05a0b428SJohn Marinodivide a finite non-zero number by zero. 49*05a0b428SJohn Marino.It Dv FE_INEXACT 50*05a0b428SJohn MarinoAn inexact exception is raised whenever there is a loss of precision 51*05a0b428SJohn Marinodue to rounding. 52*05a0b428SJohn Marino.It Dv FE_INVALID 53*05a0b428SJohn MarinoInvalid operation exceptions occur when a program attempts to 54*05a0b428SJohn Marinoperform calculations for which there is no reasonable representable 55*05a0b428SJohn Marinoanswer. 56*05a0b428SJohn Marino.Pp 57*05a0b428SJohn MarinoFor instance, subtraction of infinities, division of zero by zero, 58*05a0b428SJohn Marinoordered comparison involving \*(Nas, and taking the square root of a 59*05a0b428SJohn Marinonegative number are all invalid operations. 60*05a0b428SJohn Marino.It Dv FE_OVERFLOW 61*05a0b428SJohn MarinoAn overflow exception occurs when the magnitude of the result of a 62*05a0b428SJohn Marinocomputation is too large to fit in the destination type. 63*05a0b428SJohn Marino.It Dv FE_UNDERFLOW 64*05a0b428SJohn MarinoUnderflow occurs when the result of a computation is too close to zero 65*05a0b428SJohn Marinoto be represented as a non-zero value in the destination type. 66*05a0b428SJohn Marino.It Dv FE_DENORMAL 67*05a0b428SJohn MarinoDenormalization exception occurs when the result of a floating-point 68*05a0b428SJohn Marinoexpression is a denormalized number. 69*05a0b428SJohn Marino.Pp 70*05a0b428SJohn MarinoThis is available only on the floating-point implementations of 71*05a0b428SJohn Marinoamd64 and i386 processors. 72*05a0b428SJohn Marino.El 73*05a0b428SJohn Marino.Pp 74*05a0b428SJohn MarinoAdditionally, the macro 75*05a0b428SJohn Marino.Dv FE_ALL_EXCEPT 76*05a0b428SJohn Marinois simply the bitwise OR of all floating-point exception macros 77*05a0b428SJohn Marinolisted above. 78*05a0b428SJohn Marino.Pp 79*05a0b428SJohn MarinoThe 80*05a0b428SJohn Marino.Fn feclearexcept 81*05a0b428SJohn Marinofunction clears the floating-point exceptions represented by 82*05a0b428SJohn Marino.Fa excepts . 83*05a0b428SJohn Marino.Pp 84*05a0b428SJohn MarinoThe 85*05a0b428SJohn Marino.Fn fegetexceptflag 86*05a0b428SJohn Marinofunction stores a representation of the states of the floating-point 87*05a0b428SJohn Marinoflags indicated by 88*05a0b428SJohn Marino.Pa excepts 89*05a0b428SJohn Marinoin the object pointed to by 90*05a0b428SJohn Marino.Pa flagp . 91*05a0b428SJohn Marino.Pp 92*05a0b428SJohn MarinoThe 93*05a0b428SJohn Marino.Fn feraiseexcept 94*05a0b428SJohn Marinofunction raises floating-point exceptions represented by 95*05a0b428SJohn Marino.Pa excepts . 96*05a0b428SJohn Marino.Pp 97*05a0b428SJohn MarinoThe 98*05a0b428SJohn Marino.Fn fesetexceptflag 99*05a0b428SJohn Marinofunction sets the floating-point status flags indicated by 100*05a0b428SJohn Marino.Pa excepts 101*05a0b428SJohn Marinoto the states stored in the object pointed to by 102*05a0b428SJohn Marino.Pa flagp . 103*05a0b428SJohn MarinoThe value of 104*05a0b428SJohn Marino.Pa flagp 105*05a0b428SJohn Marinoshall have been set by a previous call to 106*05a0b428SJohn Marino.Fn fegetexceptflag 107*05a0b428SJohn Marinowhose second argument represented at least those floating-point 108*05a0b428SJohn Marinoexceptions represented by 109*05a0b428SJohn Marino.Pa excepts . 110*05a0b428SJohn MarinoThis function does not raise floating-point exceptions, but only 111*05a0b428SJohn Marinosets the state of the flags. 112*05a0b428SJohn Marino.Pp 113*05a0b428SJohn MarinoThe 114*05a0b428SJohn Marino.Fn fetesteexcept 115*05a0b428SJohn Marinofunction determines which of a specified subset of the floating-point 116*05a0b428SJohn Marinoexception flags are currently set. 117*05a0b428SJohn MarinoThe 118*05a0b428SJohn Marino.Pa excepts 119*05a0b428SJohn Marinospecifies the floating-point status flags to be queried. 120*05a0b428SJohn Marino.Sh RETURN VALUES 121*05a0b428SJohn MarinoThe 122*05a0b428SJohn Marino.Fn feclearexcept , 123*05a0b428SJohn Marino.Fn fegetexceptflag , 124*05a0b428SJohn Marino.Fn feraiseexcept , 125*05a0b428SJohn Marinoand 126*05a0b428SJohn Marino.Fn fesetexceptflag 127*05a0b428SJohn Marinofunctions return zero on success, and non-zero if an error occurred. 128*05a0b428SJohn MarinoThe 129*05a0b428SJohn Marino.Fn fetestexcept 130*05a0b428SJohn Marinofunction returns a bitmask of a specified subset of the floating-point 131*05a0b428SJohn Marinoexception flags which are currently set. 132*05a0b428SJohn Marino.Sh SEE ALSO 133*05a0b428SJohn Marino.Xr feenableexcept 3 , 134*05a0b428SJohn Marino.Xr fegetenv 3 , 135*05a0b428SJohn Marino.Xr fegetround 3 136*05a0b428SJohn Marino.Sh STANDARDS 137*05a0b428SJohn MarinoThe 138*05a0b428SJohn Marino.Fn feclearexcept , 139*05a0b428SJohn Marino.Fn fegetexceptflag , 140*05a0b428SJohn Marino.Fn feraiseexcept , 141*05a0b428SJohn Marino.Fn fesetexceptflag , 142*05a0b428SJohn Marinoand 143*05a0b428SJohn Marino.Fn fetestexcept 144*05a0b428SJohn Marinofunctions conform to 145*05a0b428SJohn Marino.St -isoC-99 . 146*05a0b428SJohn Marino.Pp 147*05a0b428SJohn MarinoThe return types for 148*05a0b428SJohn Marino.Fn feclearexcept , 149*05a0b428SJohn Marino.Fn fegetexceptflag , 150*05a0b428SJohn Marino.Fn feraiseexcept , 151*05a0b428SJohn Marinoand 152*05a0b428SJohn Marino.Fn fesetexceptflag 153*05a0b428SJohn Marinoare 154*05a0b428SJohn Marino.Vt int 155*05a0b428SJohn Marinofor alignment with 156*05a0b428SJohn Marino.St -isoC-99 157*05a0b428SJohn MarinoDefect Report #202. 158*05a0b428SJohn Marino.Sh HISTORY 159*05a0b428SJohn MarinoThese functions first appeared in 160*05a0b428SJohn Marino.Ox 5.0 . 161*05a0b428SJohn Marino.Sh CAVEATS 162*05a0b428SJohn MarinoOn some architectures, 163*05a0b428SJohn Marino.Fn feraiseexcept 164*05a0b428SJohn Marinoadditionally raises the 165*05a0b428SJohn Marino.Dq inexact 166*05a0b428SJohn Marinofloating-point exception whenever it raises the 167*05a0b428SJohn Marino.Dq overflow 168*05a0b428SJohn Marinoor 169*05a0b428SJohn Marino.Dq underflow 170*05a0b428SJohn Marinofloating-point exception. 171