Ray's Knowledge Base
Unlock

Use double_text for shortest round-trip group keys and statistics

PitfallVerified 30 Sep 2026Holds project: dftracer-utils
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

Textual group keys or statistics change from 2.5 to 2.500000.

Cause#

std::to_string(double) uses formatting that does not match the project's shortest round-trip representation.

Fix#

Use double_text from core/common/to_chars.h, built on to_chars_double.

Evidence#

Observer inbox 5f2574cd39 identifies the formatting difference and the shared helper. It does not preserve a standalone test command.

Also found by searching

  • group key printed as 2.500000 instead of 2.5 in aggregation output
  • statistics and group keys in my C++ output show trailing zeros after a change
  • how do I format doubles shortest round-trip in dftracer-utils instead of std::to_string?
  • std::to_string(double) six decimals mismatch, use to_chars based helper for shortest representation
  • group keys print 2.500000 instead of 2.5 in output
  • std::to_string(double) gives trailing zeros in group-by key text
  • which helper formats doubles with shortest round trip representation in dftracer-utils?
  • statistics text output changed from 2.5 to 2.500000, to_chars_double