Default StringMaker<FloatingPointType>::precision to max_digits10

`max_digits10` is the number of decimal digits that the type _can_
represent, in other words, the number of decimal digits needed to
disambiguate any two floating point numbers when serialized to
a string.
This commit is contained in:
Martin Hořeňovský
2024-04-30 16:43:05 +02:00
parent efb39689d9
commit ef713582d2
18 changed files with 2109 additions and 1071 deletions

View File

@@ -239,13 +239,13 @@ std::string StringMaker<unsigned char>::convert(unsigned char value) {
return ::Catch::Detail::stringify(static_cast<char>(value));
}
int StringMaker<float>::precision = 5;
int StringMaker<float>::precision = std::numeric_limits<float>::max_digits10;
std::string StringMaker<float>::convert(float value) {
return Detail::fpToString(value, precision) + 'f';
}
int StringMaker<double>::precision = 10;
int StringMaker<double>::precision = std::numeric_limits<double>::max_digits10;
std::string StringMaker<double>::convert(double value) {
return Detail::fpToString(value, precision);