3 ms·
> Even user-defined literals in C++11 and later don't let you express custom floating point expressions Note that in your code sample you're not actually using
by svat 8y ago
> Even user-defined literals in C++11 and later don't let you express custom floating point expressions
Note that in your code sample you're not actually using user-defined literals (https://en.cppreference.com/w/cpp/language/user_literal https://en.cppreference.com/w/cpp/language/user_literal). This works (based on on your earlier code sample and adding user-defined literals):
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/lexical_cast.hpp>
#include <iostream>
using fl50 = boost::multiprecision::cpp_dec_float_50;
fl50 operator"" _w(const char* s) { return boost::lexical_cast<fl50>(s); }
int main() {
fl50 a = 9999999999999999.7_w;
fl50 b = 9999999999999998.5_w;
std::cout << (a - b) << "\n";
}
- nly 8y agoThanks, it's nice to be wrong! For some reason I had it in my head that you couldn't get the token as a char const* for floating point expressions...