folly::json::FloatFormat

Specifies how to format floating-point values in serialized JSON output.

Synopsis

Declared in <folly/json/json.h>

enum class FloatFormat : int;

Description

Each enum value maps to a fixed fmt format string at the printer dispatch site, so there is no runtime fmt-spec parsing on the serialization hot path.

Members

NameDescription
SHORTEST Shortest decimal that round-trips back to the exact same IEEE-754 double (equivalent to fmt::format("{}", x)).
SHORTEST_TRAILING_DOT_ZERO Like SHORTEST, but always emits a decimal point and at least one fractional digit (e.g. 123 becomes 123.0, 3e-06 becomes 3.0e-06).
SHORTEST_SINGLE Like SHORTEST, but uses single-precision rounding: the shortest decimal that round-trips to the same IEEE-754 float (equivalent to fmt::format("{}", static_cast<float>(x))).
SHORTEST_SINGLE_TRAILING_DOT_ZERO Like SHORTEST_SINGLE, but always emits a decimal point and at least one fractional digit (e.g. 123 becomes 123.0, 3e-06 becomes 3.0e-06).
FIXED Fixed-point notation with double_num_digits digits after the decimal point (equivalent to fmt::format("{:.{}f}", x, double_num_digits)).
GENERAL General-precision notation (%g semantics) with double_num_digits significant digits, stripping trailing zeros.