2 [section:rounding Rounding Truncation and Integer Conversion]
4 [section:round Rounding Functions]
6 ``#include <boost/math/special_functions/round.hpp>``
11 template <class T, class Policy>
12 T round(const T& v, const Policy&);
15 int iround(const T& v);
17 template <class T, class Policy>
18 int iround(const T& v, const Policy&);
21 long lround(const T& v);
23 template <class T, class Policy>
24 long lround(const T& v, const Policy&);
27 long long llround(const T& v);
29 template <class T, class Policy>
30 long long llround(const T& v, const Policy&);
32 These functions return the closest integer to the argument /v/.
34 Halfway cases are rounded away from zero, regardless of the current rounding
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`.
43 [section:trunc Truncation Functions]
45 ``#include <boost/math/special_functions/trunc.hpp>``
50 template <class T, class Policy>
51 T trunc(const T& v, const Policy&);
54 int itrunc(const T& v);
56 template <class T, class Policy>
57 int itrunc(const T& v, const Policy&);
60 long ltrunc(const T& v);
62 template <class T, class Policy>
63 long ltrunc(const T& v, const Policy&);
66 long long lltrunc(const T& v);
68 template <class T, class Policy>
69 long long lltrunc(const T& v, const Policy&);
71 The trunc functions round their argument to the integer value,
72 nearest to but no larger in magnitude than the argument.
74 For example `itrunc(3.7)` would return `3` and `ltrunc(-4.6)`
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`.
83 [section:modf Integer and Fractional Part Splitting (modf)]
85 ``#include <boost/math/special_functions/modf.hpp>``
88 T modf(const T& v, T* ipart);
90 template <class T, class Policy>
91 T modf(const T& v, T* ipart, const Policy&);
94 T modf(const T& v, int* ipart);
96 template <class T, class Policy>
97 T modf(const T& v, int* ipart, const Policy&);
100 T modf(const T& v, long* ipart);
102 template <class T, class Policy>
103 T modf(const T& v, long* ipart, const Policy&);
106 T modf(const T& v, long long* ipart);
108 template <class T, class Policy>
109 T modf(const T& v, long long* ipart, const Policy&);
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/.
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`.
122 [endsect] [/section:rounding Rounding Truncation and Integer Conversion]
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).