fmt/include
hexonal 6c285ba88a
Format zero as 0x0p+0 in hexfloat (#4878)
fmt::format("{:a}", 0.0) produced 0x0p-1022 where printf's %a gives
0x0p+0, and likewise for -0.0, {:A}, {:#a} and any explicit precision.

basic_fp::assign maps a zero biased exponent to 1 ("subnormals use
biased exponent 1"), which is right for subnormals but not for zero, so
format_hexfloat inherited the minimum subnormal exponent for a value
whose significand carries no information. Reset the exponent there
rather than in assign, which the decimal path shares.

A zero significand can only come from +-0: normals get the implicit bit
added, and a subnormal has a nonzero significand by definition. So the
guard cannot affect anything else, and denorm_min keeps its existing
denormalized form (0x0.0000000000001p-1022, asserted in format_double).

The five new expectations were taken from printf rather than derived,
and all fail without this change.
2026-08-10 09:52:03 -07:00
..
fmt Format zero as 0x0p+0 in hexfloat (#4878) 2026-08-10 09:52:03 -07:00