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
@@ -757,8 +757,15 @@ TEST_F(NodeEmitterTest, SimpleFlowSeqNode) {
|
||||
node.push_back(1.5);
|
||||
node.push_back(2.25);
|
||||
node.push_back(3.125);
|
||||
node.push_back(34.34);
|
||||
node.push_back(56.56);
|
||||
node.push_back(12.12);
|
||||
node.push_back(78.78);
|
||||
node.push_back(0.0003);
|
||||
node.push_back(4000.);
|
||||
node.push_back(1.5474251e+26f);
|
||||
|
||||
ExpectOutput("[1.5, 2.25, 3.125]", node);
|
||||
ExpectOutput("[1.5, 2.25, 3.125, 34.34, 56.56, 12.12, 78.78, 0.0003, 4000, 1.5474251e+26]", node);
|
||||
}
|
||||
|
||||
TEST_F(NodeEmitterTest, NestFlowSeqNode) {
|
||||
|
Reference in New Issue
Block a user