Sprout/sprout/rational/conversion.hpp

19 lines
479 B
C++
Raw Normal View History

2012-08-28 16:16:12 +00:00
#ifndef SPROUT_RATIONAL_CONVERSION_HPP
#define SPROUT_RATIONAL_CONVERSION_HPP
#include <sprout/config.hpp>
#include <sprout/rational/rational.hpp>
namespace sprout {
//
// rational_cast
//
template<typename T, typename IntType>
inline SPROUT_CONSTEXPR T
rational_cast(sprout::rational<IntType> const& src) {
return static_cast<T>(src.numerator()) / static_cast<T>(src.denominator());
}
2013-03-22 05:24:19 +00:00
} // namespace sprout
2012-08-28 16:16:12 +00:00
#endif // SPROUT_RATIONAL_CONVERSION_HPP