Created
January 20, 2022 16:03
-
-
Save afabri/c977d9e14b925d83269ec76366aa1673 to your computer and use it in GitHub Desktop.
boost::multiprecision::mpq_rational * int and boost::multiprecision::mpq_rational + double fail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This fails with VC++ 2019 and boost 1.78 */ | |
#include <boost/multiprecision/gmp.hpp> | |
#include <iostream> | |
typedef boost::multiprecision::mpq_rational Rational; | |
int main() | |
{ | |
Rational num(2) , den("2251799813685248"); | |
Rational q = num / den; | |
std::cout << q << std::endl; | |
int zero = 0; | |
Rational rzero = q * zero; | |
std::cout << rzero << std::endl; | |
Rational rat(-0.375); | |
double d = -0.625; | |
std::cout << "rat : " << rat << std::endl; | |
Rational sub = rat - d; | |
std::cout << "sub : " << sub << std::endl; | |
assert(rat != sub); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment