Sunday, 10 January 2021

Prettier floats using yaml

Whenever I use yaml dump to dump floats, they start to look ugly.

Input:

a.yaml

a: 0.000000015

When I read it in and then dump it to file again, it will look like:

dumped.yaml

a: 1.5e-08

Note that there's no fixed size I can go for, i.e. maybe someone wants to put a lot of zeros (and I am not "afraid" of e.g. a small fraction with 20 leading zeros)

Also, if you choose a fixed size, then it might look like the following (which I am trying to avoid as well)

a: 0.0000000150000


from Prettier floats using yaml

No comments:

Post a Comment