]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/include/boost/math/special_functions/modf.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / include / boost / math / special_functions / modf.hpp
1 // Copyright John Maddock 2007.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef BOOST_MATH_MODF_HPP
7 #define BOOST_MATH_MODF_HPP
8
9 #ifdef _MSC_VER
10 #pragma once
11 #endif
12
13 #include <boost/math/special_functions/math_fwd.hpp>
14 #include <boost/math/tools/config.hpp>
15 #include <boost/math/special_functions/trunc.hpp>
16
17 namespace boost{ namespace math{
18
19 template <class T, class Policy>
20 inline T modf(const T& v, T* ipart, const Policy& pol)
21 {
22 *ipart = trunc(v, pol);
23 return v - *ipart;
24 }
25 template <class T>
26 inline T modf(const T& v, T* ipart)
27 {
28 return modf(v, ipart, policies::policy<>());
29 }
30
31 template <class T, class Policy>
32 inline T modf(const T& v, int* ipart, const Policy& pol)
33 {
34 *ipart = itrunc(v, pol);
35 return v - *ipart;
36 }
37 template <class T>
38 inline T modf(const T& v, int* ipart)
39 {
40 return modf(v, ipart, policies::policy<>());
41 }
42
43 template <class T, class Policy>
44 inline T modf(const T& v, long* ipart, const Policy& pol)
45 {
46 *ipart = ltrunc(v, pol);
47 return v - *ipart;
48 }
49 template <class T>
50 inline T modf(const T& v, long* ipart)
51 {
52 return modf(v, ipart, policies::policy<>());
53 }
54
55 #ifdef BOOST_HAS_LONG_LONG
56 template <class T, class Policy>
57 inline T modf(const T& v, boost::long_long_type* ipart, const Policy& pol)
58 {
59 *ipart = lltrunc(v, pol);
60 return v - *ipart;
61 }
62 template <class T>
63 inline T modf(const T& v, boost::long_long_type* ipart)
64 {
65 return modf(v, ipart, policies::policy<>());
66 }
67 #endif
68
69 }} // namespaces
70
71 #endif // BOOST_MATH_MODF_HPP