Skip to content

Reduce fmt usage in String() methods#259

Merged
dgryski merged 3 commits into
mainfrom
case/reduce-fmt
May 23, 2026
Merged

Reduce fmt usage in String() methods#259
dgryski merged 3 commits into
mainfrom
case/reduce-fmt

Conversation

@case-fastly

Copy link
Copy Markdown
Member

This addresses #199.

Also found a small bug in there:

When nearest3 rounds to a whole number (fract == 0), the function falls into the integer branch. But that branch formats int32(f) — the original unrounded input — not int32(nearest3).

Here's an example: https://go.dev/play/p/OahudI8zyfH

@dgryski

dgryski commented May 22, 2026

Copy link
Copy Markdown
Member

The nearest3 code is a direct translation of the Rust: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=878c4313bfa509636e7d46941e99c987

We should fix that too.

@dgryski dgryski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Only comment would be if we wanted to call .String() on a few of types instead of using string(x) so we don't break that encapsulation?

@dgryski dgryski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dgryski dgryski merged commit 17ca001 into main May 23, 2026
7 checks passed
@dgryski dgryski deleted the case/reduce-fmt branch May 23, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants