test_float_conversions.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ///////////////////////////////////////////////////////////////
  2. // Copyright 2015 John Maddock. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
  5. //
  6. #ifdef _MSC_VER
  7. #define _SCL_SECURE_NO_WARNINGS
  8. #endif
  9. #include <boost/detail/lightweight_test.hpp>
  10. #include <boost/array.hpp>
  11. #include "test.hpp"
  12. #include <boost/multiprecision/cpp_bin_float.hpp>
  13. #include <boost/math/constants/constants.hpp>
  14. int main()
  15. {
  16. using namespace boost::multiprecision;
  17. BOOST_STATIC_ASSERT((boost::is_convertible<float, cpp_bin_float_single>::value));
  18. BOOST_STATIC_ASSERT(!(boost::is_convertible<double, cpp_bin_float_single>::value));
  19. BOOST_STATIC_ASSERT(!(boost::is_convertible<long double, cpp_bin_float_single>::value));
  20. cpp_bin_float_single s = boost::math::constants::pi<cpp_bin_float_single>();
  21. typedef number<backends::cpp_bin_float<11, backends::digit_base_2, void, boost::int8_t, -14, 15>, et_off> cpp_bin_float_half;
  22. BOOST_STATIC_ASSERT(!(boost::is_convertible<float, cpp_bin_float_half>::value));
  23. BOOST_STATIC_ASSERT(!(boost::is_convertible<double, cpp_bin_float_half>::value));
  24. BOOST_STATIC_ASSERT(!(boost::is_convertible<long double, cpp_bin_float_half>::value));
  25. #ifdef BOOST_HAS_FLOAT128
  26. BOOST_STATIC_ASSERT(!(boost::is_convertible<__float128, cpp_bin_float_half>::value));
  27. #endif
  28. cpp_bin_float_half hs = boost::math::constants::pi<cpp_bin_float_half>();
  29. return boost::report_errors();
  30. }