jbeder / yaml-cpp

A YAML parser and emitter in C++
MIT License
5.04k stars 1.81k forks source link

Emitting Float With Trailing Decimal .0 #412

Open LemonPi opened 8 years ago

LemonPi commented 8 years ago

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.

arneboe commented 2 years ago

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