// Shared numeric formatters for inspector and report views. // // Engine wire-format for floats is `Fixed3` quantised // (pkg/model/report/report.go). The UI renders them as a fixed 3-decimal // string with neither thousand separators nor locale-aware grouping — // values stay column-aligned across rows and never reflow when the locale // switches mid-session. Integer counts (planet count, ship `count`) are // rendered with zero fractional digits to match their wire shape // (uint16 / uint64). The convention mirrors the calculator-tab view // (`useGrouping: false`, 3 decimals) so inspector and report tables read // the same way as the calculator panel. /** * formatFloat renders an engine-emitted `Float` with three fractional * digits and no thousand separators. Used for tech levels, stockpiles, * coordinates, range, mass, votes — every report payload that is not * an integer count or a `[0, 1]` fraction. */ export function formatFloat(value: number): string { return value.toFixed(3); } /** * formatInt renders an integer-ish count (planet count, ship count, * etc.) with zero fractional digits and no thousand separators. */ export function formatInt(value: number): string { return value.toFixed(0); } /** * formatPercent renders a `[0, 1]` fraction as a one-decimal percent * without a `%` suffix — the column header carries the unit. 0.1 % * precision (the third decimal of the underlying float) matches the * project-wide "three decimal digits" convention used elsewhere by * `formatFloat`. */ export function formatPercent(fraction: number): string { return (fraction * 100).toFixed(1); }