Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMartin Hořeňovský2024-04-30 16:43:05 +0200
committerMartin Hořeňovský2024-04-30 17:18:48 +0200
commitef713582d268d9b1b15381325021d7e0f91d6ab9 (patch)
treebb9f73173f9ad2a4fc4c1dd56080a7f50fb5f702 /src
parentefb39689d94e43132e4e48f01e676ae6a56d8df6 (diff)
downloadcatch3-ef713582d268d9b1b15381325021d7e0f91d6ab9.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/catch2/catch_tostring.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/catch2/catch_tostring.cpp b/src/catch2/catch_tostring.cpp
index b0b53c5e..3f034d1a 100644
--- a/src/catch2/catch_tostring.cpp
+++ b/src/catch2/catch_tostring.cpp
@@ -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);