Remove advertising header from man pages.
[dragonfly.git] / share / man / man3 / fpgetround.3
1 .\" Copyright (c) 1993 Andrew Moore, Talke Studio
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)fpgetround.3        1.0 (Berkeley) 9/23/93
29 .\" $FreeBSD: src/share/man/man3/fpgetround.3,v 1.15 2005/07/15 17:35:25 hrs Exp $
30 .\" $DragonFly: src/share/man/man3/fpgetround.3,v 1.4 2008/05/02 02:05:05 swildner Exp $
31 .\"
32 .Dd April 23, 2009
33 .Dt FPGETROUND 3
34 .Os
35 .Sh NAME
36 .Nm fpgetround ,
37 .Nm fpsetround ,
38 .Nm fpsetprec ,
39 .Nm fpgetprec ,
40 .Nm fpgetmask ,
41 .Nm fpsetmask ,
42 .Nm fpgetsticky ,
43 .Nm fpsetsticky ,
44 .Nm fpresetsticky
45 .Nd IEEE floating point interface
46 .Sh LIBRARY
47 .Lb libc
48 .Sh SYNOPSIS
49 .In ieeefp.h
50 .Bd -literal
51 typedef enum {
52         FP_RN,          /* round to nearest */
53         FP_RM,          /* round down to minus infinity */
54         FP_RP,          /* round up to plus infinity */
55         FP_RZ           /* truncate */
56 } fp_rnd_t;
57 .Ed
58 .Ft fp_rnd_t
59 .Fn fpgetround void
60 .Ft fp_rnd_t
61 .Fn fpsetround "fp_rnd_t direction"
62 .Bd -literal
63 typedef enum {
64         FP_PS,          /* 24 bit (single-precision) */
65         FP_PRS,         /* reserved */
66         FP_PD,          /* 53 bit (double-precision) */
67         FP_PE           /* 64 bit (extended-precision) */
68 } fp_prec_t;
69 .Ed
70 .Ft fp_prec_t
71 .Fn fpgetprec void
72 .Ft fp_prec_t
73 .Fn fpsetprec "fp_prec_t precision"
74 .Bd -literal
75 #define fp_except_t     int
76 #define FP_X_INV        0x01    /* invalid operation */
77 #define FP_X_DNML       0x02    /* denormal */
78 #define FP_X_DZ         0x04    /* zero divide */
79 #define FP_X_OFL        0x08    /* overflow */
80 #define FP_X_UFL        0x10    /* underflow */
81 #define FP_X_IMP        0x20    /* (im)precision */
82 #define FP_X_STK        0x40    /* stack fault */
83 .Ed
84 .Ft fp_except_t
85 .Fn fpgetmask void
86 .Ft fp_except_t
87 .Fn fpsetmask "fp_except_t mask"
88 .Ft fp_except_t
89 .Fn fpgetsticky void
90 .Ft fp_except_t
91 .Fn fpsetsticky "fp_except_t sticky"
92 .Ft fp_except_t
93 .Fn fpresetsticky "fp_except_t sticky"
94 .Sh DESCRIPTION
95 The routines described herein are deprecated.
96 New code should use the functionality provided by
97 .Xr fenv 3 .
98 .Pp
99 When a floating point exception is detected, the exception sticky flag is
100 set and the exception mask is tested.
101 If the mask is set, then a trap occurs.
102 These routines allow both setting the floating point exception
103 masks, and resetting the exception sticky flags after an exception is
104 detected.
105 In addition, they allow setting the floating point rounding mode
106 and precision.
107 .Pp
108 The
109 .Fn fpgetround
110 function
111 returns the current floating point rounding mode.
112 .Pp
113 The
114 .Fn fpsetround
115 function
116 sets the floating point rounding mode and returns
117 the previous mode.
118 .Pp
119 The
120 .Fn fpgetprec
121 function
122 returns the current floating point precision.
123 .Pp
124 The
125 .Fn fpsetprec
126 function
127 sets the floating point precision and returns
128 the previous precision.
129 .Pp
130 The
131 .Fn fpgetmask
132 function
133 returns the current floating point exception masks.
134 .Pp
135 The
136 .Fn fpsetmask
137 function
138 sets the floating point exception masks and returns the
139 previous masks.
140 .Pp
141 The
142 .Fn fpgetsticky
143 function
144 returns the current floating point sticky flags.
145 .Pp
146 The
147 .Fn fpsetsticky
148 sets the floating point sticky flags and returns
149 the previous flags.
150 .Pp
151 The
152 .Fn fpresetsticky
153 function
154 clears the floating point sticky flags and returns
155 the previous flags.
156 .Pp
157 Sample code which prevents a trap on divide-by-zero:
158 .Bd -literal -offset indent
159 fpsetmask(~FP_X_DZ);
160 a = 1.0;
161 b = 0;
162 c = a / b;
163 fpresetsticky(FP_X_DZ);
164 fpsetmask(FP_X_DZ);
165 .Ed
166 .Sh IMPLEMENTATION NOTES
167 The
168 .Fn fpgetprec
169 and
170 .Fn fpsetprec
171 functions provide functionality unavailable on many platforms.
172 At present, they are implemented only on the i386 and x86_64 platforms.
173 .Sh SEE ALSO
174 .Xr fenv 3 ,
175 .Xr isnan 3
176 .Sh CAVEATS
177 After a floating point exception and before a mask is set, the sticky
178 flags must be reset.
179 If another exception occurs before the sticky
180 flags are reset, then a wrong exception type may be signaled.
181 .Sh HISTORY
182 These routines are based on SysV/386 routines of the same name.