Ticket #12525: af_p2.cpp

File af_p2.cpp, 542 bytes (added by Michael Shatz, 6 years ago)

demonstrates unexpected sign of zero as result of trunc()

Line 
1#include <iostream>
2#include <boost/multiprecision/cpp_bin_float.hpp>
3
4typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float<128, boost::multiprecision::backends::digit_base_2> > boost_quadfloat_t;
5
6int main(int , char** )
7{
8 double x = -0.5;
9 double y = trunc(x);
10 boost_quadfloat_t bx = x;
11 boost_quadfloat_t by = trunc(bx);
12
13 std::cout
14 << "double: "
15 << "trunc(" << x << ") => " << y
16 << ";\ncpp_bin_float: "
17 << "trunc(" << bx << ") => " << by
18 << "\n"
19 ;
20
21 return 0;
22}