mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
fix: prettier floating point numbers
Add dragonbox to compute the required precision to print floating point numbers. This avoids uglification of floating point numbers that happen by default via std::stringstream. Numbers like 34.34 used to be converted to '34.340000000000003' as strings. With this version they will be converted to the string '34.34'. This fixes issue https://github.com/jbeder/yaml-cpp/issues/1289
This commit is contained in:

committed by
Jesse Beder

parent
3d2888cc8a
commit
bd070a7b76
@@ -104,9 +104,11 @@ TEST_F(EmitterTest, NumberPrecision) {
|
||||
out << 3.1425926f;
|
||||
out << 53.5893;
|
||||
out << 2384626.4338;
|
||||
out << 1999926.4338;
|
||||
out << 9999926.4338;
|
||||
out << EndSeq;
|
||||
|
||||
ExpectEmit("- 3.14\n- 54\n- 2.4e+06");
|
||||
ExpectEmit("- 3.14\n- 54\n- 2.4e+06\n- 2e+06\n- 1e+07");
|
||||
}
|
||||
|
||||
TEST_F(EmitterTest, SimpleSeq) {
|
||||
|
Reference in New Issue
Block a user