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