Skip to content

Fix floating-point display imprecision for cost/increment values in admin panels#157

Merged
tastybento merged 2 commits intodevelopfrom
copilot/fix-increment-accuracy
Apr 13, 2026
Merged

Fix floating-point display imprecision for cost/increment values in admin panels#157
tastybento merged 2 commits intodevelopfrom
copilot/fix-increment-accuracy

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

Cost values entered by admins (e.g. 0.03) were displayed as their full IEEE 754 double representation (0.0299999999329447746) in GUI tooltips due to bare String.valueOf(double) calls.

Changes

  • Utils — Added formatDouble(double) using a ThreadLocal<DecimalFormat> with pattern "0.###": up to 3 decimal places, trailing zeros stripped, thread-safe for concurrent panel access across players.
// Before
String.valueOf(this.biome.getCostIncrement())  // → "0.0299999999329447746"

// After
Utils.formatDouble(this.biome.getCostIncrement())  // → "0.03"
  • BiomeEditPanel — Applied Utils.formatDouble() to the three double-typed cost fields displayed in the admin edit panel: unlock cost, change cost, and cost increment.
  • CommonPanel — Applied Utils.formatDouble() to unlock cost in the biome description lore.

Copilot AI linked an issue Apr 13, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix increment calculation for floating point accuracy Fix floating-point display imprecision for cost/increment values in admin panels Apr 13, 2026
Copilot AI requested a review from tastybento April 13, 2026 05:10
@tastybento tastybento marked this pull request as ready for review April 13, 2026 05:11
@tastybento tastybento merged commit b58511e into develop Apr 13, 2026
@tastybento tastybento deleted the copilot/fix-increment-accuracy branch April 13, 2026 05:11
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.

Change increment is not accurate

2 participants