This is particularly sucky to solve in C and C++ because you don't get arbitrary precision literals. #include #include #include using fl50 = boost::multiprecision::cpp_dec_float_50; int main() { auto a = boost::lexical_cast ("9999999999999999.7"); auto b = boost::lexical_cast ("9999999999999998.5"); std::cout works int main() { fl50 a = 9999999999999999.7; fl50 b = 9999999999999998.5; std::cout doesn't, even if you c…
Note that in your code sample you're not actually using user-defined literals (https://en.cppreference.com/w/cpp/language/user_literal). This works (based on on your earlier code sample and adding user-defined literals):
#include
#include
#include
using fl50 = boost::multiprecision::cpp_dec_float_50;
fl50 operator"" _w(const char* s) { return boost::lexical_cast(s); }
int main() {
fl50 a = 9999999999999999.7_w;
fl50 b = 9999999999999998.5_w;
std::cout