yaml-cpp icon indicating copy to clipboard operation
yaml-cpp copied to clipboard

Emitting Float With Trailing Decimal .0

Open LemonPi opened this issue 9 years ago • 1 comments
trafficstars

Currently any float/double with no decimal component gets emitted as an integer.

float a = 1.0;
YAML::Emitter emitter;

// regardless of the Precision manipulator
emitter << YAML::Precision(2) << a;

// outputs 1

Is there a way to make it output 1.0?

The YAML file I'm emitting should have a mix of ints and floats, which gets parsed by an external script. That script needs to be able to distinguish floats and ints.

LemonPi avatar Aug 23 '16 14:08 LemonPi

Did you ever find a solution for this? I am facing the same problem

arneboe avatar Jan 05 '22 12:01 arneboe