1FEGETROUND(P) POSIX Programmer's Manual FEGETROUND(P)
2
3
4
6 fegetround, fesetround - get and set current rounding direction
7
9 #include <fenv.h>
10
11 int fegetround(void);
12 int fesetround(int round);
13
14
16 The fegetround() function shall get the current rounding direction.
17
18 The fesetround() function shall establish the rounding direction repre‐
19 sented by its argument round. If the argument is not equal to the value
20 of a rounding direction macro, the rounding direction is not changed.
21
23 The fegetround() function shall return the value of the rounding direc‐
24 tion macro representing the current rounding direction or a negative
25 value if there is no such rounding direction macro or the current
26 rounding direction is not determinable.
27
28 The fesetround() function shall return a zero value if and only if the
29 requested rounding direction was established.
30
32 No errors are defined.
33
34 The following sections are informative.
35
37 The following example saves, sets, and restores the rounding direction,
38 reporting an error and aborting if setting the rounding direction
39 fails:
40
41
42 #include <fenv.h>
43 #include <assert.h>
44 void f(int round_dir)
45 {
46 #pragma STDC FENV_ACCESS ON
47 int save_round;
48 int setround_ok;
49 save_round = fegetround();
50 setround_ok = fesetround(round_dir);
51 assert(setround_ok == 0);
52 /* ... */
53 fesetround(save_round);
54 /* ... */
55 }
56
58 None.
59
61 None.
62
64 None.
65
67 The Base Definitions volume of IEEE Std 1003.1-2001, <fenv.h>
68
70 Portions of this text are reprinted and reproduced in electronic form
71 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
72 -- Portable Operating System Interface (POSIX), The Open Group Base
73 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
74 Electrical and Electronics Engineers, Inc and The Open Group. In the
75 event of any discrepancy between this version and the original IEEE and
76 The Open Group Standard, the original IEEE and The Open Group Standard
77 is the referee document. The original Standard can be obtained online
78 at http://www.opengroup.org/unix/online.html .
79
80
81
82IEEE/The Open Group 2003 FEGETROUND(P)