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)
6 #ifndef BOOST_MATH_MODF_HPP
7 #define BOOST_MATH_MODF_HPP
13 #include <boost/math/special_functions/math_fwd.hpp>
14 #include <boost/math/tools/config.hpp>
15 #include <boost/math/special_functions/trunc.hpp>
17 namespace boost{ namespace math{
19 template <class T, class Policy>
20 inline T modf(const T& v, T* ipart, const Policy& pol)
22 *ipart = trunc(v, pol);
26 inline T modf(const T& v, T* ipart)
28 return modf(v, ipart, policies::policy<>());
31 template <class T, class Policy>
32 inline T modf(const T& v, int* ipart, const Policy& pol)
34 *ipart = itrunc(v, pol);
38 inline T modf(const T& v, int* ipart)
40 return modf(v, ipart, policies::policy<>());
43 template <class T, class Policy>
44 inline T modf(const T& v, long* ipart, const Policy& pol)
46 *ipart = ltrunc(v, pol);
50 inline T modf(const T& v, long* ipart)
52 return modf(v, ipart, policies::policy<>());
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)
59 *ipart = lltrunc(v, pol);
63 inline T modf(const T& v, boost::long_long_type* ipart)
65 return modf(v, ipart, policies::policy<>());
71 #endif // BOOST_MATH_MODF_HPP