1 // (C) Copyright John Maddock 2019. 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 #include "constexpr_arithmetric_test.hpp" 7 #include <boost/multiprecision/float128.hpp> 8 #include <iostream> 9 main()10int main() 11 { 12 using boost::multiprecision::float128; 13 14 { 15 constexpr float128 a(22); 16 constexpr float128 b = test_constexpr_add_subtract(a); 17 18 constexpr __float128 f128 = (__float128)b; 19 static_assert(f128 == -134.0f); 20 21 constexpr int i = (int)b; 22 static_assert(i == -134); 23 24 constexpr short s = (short)b; 25 static_assert(s == -134); 26 } 27 { 28 constexpr float128 a(22); 29 constexpr float128 b = test_constexpr_mul_divide(a); 30 static_assert((__float128)b == 0); 31 } 32 { 33 constexpr float128 a(22); 34 constexpr float128 b = test_constexpr_compare(a); 35 static_assert((__float128)b == 119); 36 } 37 { 38 constexpr float128 a(0); 39 static_assert(fpclassify(a) == FP_ZERO); 40 constexpr float128 b(1); 41 static_assert(fpclassify(b) == FP_NORMAL); 42 constexpr float128 c(-1); 43 static_assert(fpclassify(c) == FP_NORMAL); 44 static_assert(abs(c) >= 0); 45 static_assert(fabs(c) >= 0); 46 constexpr float128 d(std::numeric_limits<float128>::epsilon()); 47 static_assert(fpclassify(c) == FP_NORMAL); 48 constexpr float128 e((std::numeric_limits<float128>::min)()); 49 static_assert(fpclassify(e) == FP_NORMAL); 50 constexpr float128 f((std::numeric_limits<float128>::max)()); 51 static_assert(fpclassify(f) == FP_NORMAL); 52 constexpr float128 g(std::numeric_limits<float128>::lowest()); 53 static_assert(fpclassify(g) == FP_NORMAL); 54 constexpr float128 h(std::numeric_limits<float128>::round_error()); 55 static_assert(fpclassify(h) == FP_NORMAL); 56 constexpr float128 i(std::numeric_limits<float128>::denorm_min()); 57 static_assert(fpclassify(i) == FP_SUBNORMAL); 58 constexpr float128 j(-std::numeric_limits<float128>::denorm_min()); 59 static_assert(fpclassify(j) == FP_SUBNORMAL); 60 constexpr float128 k(std::numeric_limits<float128>::infinity()); 61 static_assert(fpclassify(k) == FP_INFINITE); 62 static_assert(isinf(k)); 63 static_assert(!isnan(k)); 64 constexpr float128 l(-std::numeric_limits<float128>::infinity()); 65 static_assert(fpclassify(l) == FP_INFINITE); 66 static_assert(isinf(l)); 67 static_assert(!isnan(l)); 68 } 69 std::cout << "Done!" << std::endl; 70 } 71