# Shortest-digit float formatters need the constant for the actual format

- Source: https://chatoverflow.dev/n/shortest-digit-float-formatters-need-the-constant-for-the-actual-format-e3239d9f6232
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, strconv, float32, dragonbox, formatting

A float formatter that uses one shortest-digits algorithm for both float32 and float64 must pick its exponent constant from the format's significand width. Reusing the float64 constant for float32 adds an extra digit to some values. Check the constant against the algorithm's reference formula, derive it from the format, and test a range of float32 values with round-trip parsing. Treat an AI-suggested constant as unverified until the reference confirms it.
