assigning a "float128" variable with a regular "double" variable
Jacques Mequin via Boost-users <[email protected]>
| Newsgroups | gmane.comp.lib.boost.user |
|---|---|
| Message-ID | <VI1PR06MB6622DDD467AED07C803468CAE5639@VI1PR06MB6622.eurprd06.prod.outlook.com> |
I am a fresh new user ( I need to extend some EIGEN library feature by using your float128 )
How to assign a "float128" variable with a regular "double" variable ?
With my source code in attachement
double double_pi = 3.141592653589793 ;
float128 float128_pi = 3.141592653589793Q ;
produces the output that looks fine to me
double_pi =
3.141592653589793e+00
float128_pi =
3.141592653589793000000000000000000e+00
but thestatement float128_pi = double_pi ; produces
float128_pi =
3.141592653589793115997963468544185e+00
How to get 3.141592653589793000000000000000000e+00 also from an assigment ???
What am I doing wrong ?
Thanks for any help
Regards,
Jacques
_______________________________________________
Boost-users mailing list
[email protected]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
jm.cpp
(text/plain, 1.1 KB)
//
// g++ -o jm.cpp -I/JM/SOFT/boost_1_77_0 jm.cpp -lquadmath
//
#include <boost/multiprecision/float128.hpp>
#include <iostream>
using boost::multiprecision::float128 ;
int main( )
{
std::cout.setf( std::ios_base::scientific ) ;
std::cout.setf( std::ios_base::showpoint ) ; // include any trailing zeros
double double_pi = 3.141592653589793 ;
float128 float128_pi = 3.141592653589793Q ;
std::cout << " double_pi = " << std::endl << std::setprecision( std::numeric_limits<double>::digits10 ) << double_pi << std::endl << std::endl ;
std::cout << "float128_pi = " << std::endl << std::setprecision( std::numeric_limits<float128>::digits10 ) << float128_pi << std::endl << std::endl ;
float128_pi = double_pi ;
std::cout << "float128_pi = " << std::endl << std::setprecision( std::numeric_limits<float128>::digits10 ) << float128_pi << std::endl << std::endl ;
std::cout << "sizeof double_pi = " << sizeof( double_pi ) << std::endl ;
std::cout << "sizeof float128_pi = " << sizeof( float128_pi ) << std::endl << std::endl ;
}