Skip to content

fix BoxDraw so it doesn't crash if given improperly formatted string. Remove trailing zeros for FloatingPointWidget - #1338

Merged
jw098 merged 2 commits into
PokemonAutomation:mainfrom
jw098:box-draw
Jul 25, 2026
Merged

fix BoxDraw so it doesn't crash if given improperly formatted string. Remove trailing zeros for FloatingPointWidget#1338
jw098 merged 2 commits into
PokemonAutomation:mainfrom
jw098:box-draw

Conversation

@jw098

@jw098 jw098 commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

std::string tostr_fixed_no_trailing_zero(double x, int precision){
std::string str = std::format("{:.{}f}", x, precision);
if (str.find('.') != std::string::npos) {
str.erase(str.find_last_not_of('0') + 1, std::string::npos);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Scientific notation isn't possible here right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I believe so. I believe the F format doesn't use scientific notation. But the G format does.

@jw098
jw098 merged commit 087bd18 into PokemonAutomation:main Jul 25, 2026
7 checks passed
@jw098
jw098 deleted the box-draw branch July 25, 2026 04:46
Developer-Butters pushed a commit to Developer-Butters/Arduino-Source that referenced this pull request Jul 28, 2026
… Remove trailing zeros for FloatingPointWidget (PokemonAutomation#1338)

* fix BoxDraw so it doesn't crash if given improperly formatted string. Remove trailing zeros for FloatingPointWidget

* fix build
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