]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/doc/fp_utilities/rounding_func.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / math / doc / fp_utilities / rounding_func.qbk
1
2 [section:rounding Rounding Truncation and Integer Conversion]
3
4 [section:round Rounding Functions]
5
6 ``#include <boost/math/special_functions/round.hpp>``
7
8 template <class T>
9 T round(const T& v);
10
11 template <class T, class Policy>
12 T round(const T& v, const Policy&);
13
14 template <class T>
15 int iround(const T& v);
16
17 template <class T, class Policy>
18 int iround(const T& v, const Policy&);
19
20 template <class T>
21 long lround(const T& v);
22
23 template <class T, class Policy>
24 long lround(const T& v, const Policy&);
25
26 template <class T>
27 long long llround(const T& v);
28
29 template <class T, class Policy>
30 long long llround(const T& v, const Policy&);
31
32 These functions return the closest integer to the argument /v/.
33
34 Halfway cases are rounded away from zero, regardless of the current rounding
35 direction.
36
37 If the argument /v/ is either non-finite or else outside the range
38 of the result type, then returns the result of __rounding_error: by
39 default this throws an instance of `boost::math::rounding_error`.
40
41 [endsect]
42
43 [section:trunc Truncation Functions]
44
45 ``#include <boost/math/special_functions/trunc.hpp>``
46
47 template <class T>
48 T trunc(const T& v);
49
50 template <class T, class Policy>
51 T trunc(const T& v, const Policy&);
52
53 template <class T>
54 int itrunc(const T& v);
55
56 template <class T, class Policy>
57 int itrunc(const T& v, const Policy&);
58
59 template <class T>
60 long ltrunc(const T& v);
61
62 template <class T, class Policy>
63 long ltrunc(const T& v, const Policy&);
64
65 template <class T>
66 long long lltrunc(const T& v);
67
68 template <class T, class Policy>
69 long long lltrunc(const T& v, const Policy&);
70
71 The trunc functions round their argument to the integer value,
72 nearest to but no larger in magnitude than the argument.
73
74 For example `itrunc(3.7)` would return `3` and `ltrunc(-4.6)`
75 would return `-4`.
76
77 If the argument /v/ is either non-finite or else outside the range
78 of the result type, then returns the result of __rounding_error: by
79 default this throws an instance of `boost::math::rounding_error`.
80
81 [endsect]
82
83 [section:modf Integer and Fractional Part Splitting (modf)]
84
85 ``#include <boost/math/special_functions/modf.hpp>``
86
87 template <class T>
88 T modf(const T& v, T* ipart);
89
90 template <class T, class Policy>
91 T modf(const T& v, T* ipart, const Policy&);
92
93 template <class T>
94 T modf(const T& v, int* ipart);
95
96 template <class T, class Policy>
97 T modf(const T& v, int* ipart, const Policy&);
98
99 template <class T>
100 T modf(const T& v, long* ipart);
101
102 template <class T, class Policy>
103 T modf(const T& v, long* ipart, const Policy&);
104
105 template <class T>
106 T modf(const T& v, long long* ipart);
107
108 template <class T, class Policy>
109 T modf(const T& v, long long* ipart, const Policy&);
110
111 The `modf` functions store the integer part of /v/ in `*ipart`
112 and return the fractional part of /v/. The sign of the integer
113 and fractional parts are the same as the sign of /v/.
114
115 If the argument /v/ is either non-finite or else outside the range
116 of the result type, then returns the result of __rounding_error: by
117 default this throws an instance of `boost::math::rounding_error`.
118
119 [endsect]
120
121
122 [endsect] [/section:rounding Rounding Truncation and Integer Conversion]
123
124 [/
125 Copyright 2006 John Maddock and Paul A. Bristow.
126 Distributed under the Boost Software License, Version 1.0.
127 (See accompanying file LICENSE_1_0.txt or copy at
128 http://www.boost.org/LICENSE_1_0.txt).
129 ]