Skip to content

Set precision for double in FileStorage #25073

@janbth

Description

@janbth

Describe the feature and motivation

I'm using FileStorage to log data in JSON format, and is supposed to be readable. This includes numbers in double precision. However, the output is a fixed scientific notation that is very difficult to read. Example:

{
    "my_double": 5.000000000000000000e-01,
    "my_int": 5
}

What I want is this:

{
    "my_double": 0.5,
    "my_int": 5
}

I would like the possibility to set the format or precision of the output.

An optimal solution would be to get access to the underlying std::ostream (if there is one, I'm assuming C++ here) so that the user could manipulate the stream with std::setprecision() etc. A related issue is #15675.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions