[priority: high] Floating point precision errors in mana and time displays #196

Closed
opened 2026-05-29 13:05:07 +02:00 by Anexim · 3 comments
Owner

BUG: Floating point arithmetic causes ugly display values

Bug Summary

Multiple UI displays show raw JavaScript floating point precision errors instead of clean rounded numbers.

Affected Areas

1. Elemental Mana Pools display

  • Example: Shows 1.1360000000000008/10 instead of 1.14/10
  • Location: Stats tab → Element Stats → Elemental Mana Pools

2. Debug Time display

  • Example: Shows Day 1, Hour 13.119999999999896 instead of Hour 13.12
  • Location: Debug panel → Time Control

3. Duplicate "Base Regen" label with inconsistent formatting

  • Shows "Base Regen: 2/hr" AND "Base Regen: 2.00/hr" (same label, different precision)
  • Location: Stats tab → Mana Stats section
  • Cause: Two separate code paths formatting the same value differently

Expected Behavior

  • All mana values should be displayed with at most 2 decimal places (or as integers where appropriate)
  • Time values should be rounded to 2 decimal places
  • Duplicate labels should be consolidated into a single display

Investigation Needed

  • Search for toFixed(), Math.round(), or number formatting utilities
  • Check if there's a shared number formatting utility or if each component formats independently
  • Identify the Stats tab component that renders "Base Regen" twice

Priority

HIGH - Affects readability and polish of core UI

**BUG: Floating point arithmetic causes ugly display values** ### Bug Summary Multiple UI displays show raw JavaScript floating point precision errors instead of clean rounded numbers. ### Affected Areas **1. Elemental Mana Pools display** - **Example:** Shows `1.1360000000000008/10` instead of `1.14/10` - **Location:** Stats tab → Element Stats → Elemental Mana Pools **2. Debug Time display** - **Example:** Shows `Day 1, Hour 13.119999999999896` instead of `Hour 13.12` - **Location:** Debug panel → Time Control **3. Duplicate "Base Regen" label with inconsistent formatting** - Shows "Base Regen: 2/hr" AND "Base Regen: 2.00/hr" (same label, different precision) - **Location:** Stats tab → Mana Stats section - **Cause:** Two separate code paths formatting the same value differently ### Expected Behavior - All mana values should be displayed with at most 2 decimal places (or as integers where appropriate) - Time values should be rounded to 2 decimal places - Duplicate labels should be consolidated into a single display ### Investigation Needed - Search for `toFixed()`, `Math.round()`, or number formatting utilities - Check if there's a shared number formatting utility or if each component formats independently - Identify the Stats tab component that renders "Base Regen" twice ### Priority HIGH - Affects readability and polish of core UI
Anexim added the ai:todo label 2026-05-29 13:05:07 +02:00
n8n-gitea was assigned by Anexim 2026-05-29 13:05:07 +02:00
Author
Owner

Starting investigation of floating point precision errors in mana/time displays.

Starting investigation of floating point precision errors in mana/time displays.
Author
Owner

Additional affected locations found during playtesting:

  • Debug > Elements > Transference mana pool: Shows 1.7120000000000013/10 instead of a clean value — same floating-point precision bug as the Stats tab Elemental Mana Pools display.
  • Debug > Game State > Mana Debug: Shows Current: 57.691520000000054 / 100 — the raw float is displayed without rounding.
  • Debug > Game State > Time Control: Shows Day 1, Hour 8.5599999999999993 — same issue as the Time Control display in the bug report.

All three are the same root cause: raw JavaScript floating-point values being rendered without toFixed() or rounding. These are additional locations to fix when addressing this issue, not separate bugs.

Additional affected locations found during playtesting: - **Debug > Elements > Transference mana pool:** Shows `1.7120000000000013/10` instead of a clean value — same floating-point precision bug as the Stats tab Elemental Mana Pools display. - **Debug > Game State > Mana Debug:** Shows `Current: 57.691520000000054 / 100` — the raw float is displayed without rounding. - **Debug > Game State > Time Control:** Shows `Day 1, Hour 8.5599999999999993` — same issue as the Time Control display in the bug report. All three are the same root cause: raw JavaScript floating-point values being rendered without `toFixed()` or rounding. These are additional locations to fix when addressing this issue, not separate bugs.
Author
Owner

Fixed three floating point display issues:

  1. Elemental Mana Pools (ElementStatsSection.tsx): Raw state.current/state.max values now formatted with fmtDec(state.current, 2) / fmtDec(state.max, 0) to show clean 2-decimal values.

  2. Debug Time display (GameStateDebug.tsx): Hour value now displayed with hour.toFixed(2) instead of raw float.

  3. Duplicate "Base Regen" label (ManaStatsSection.tsx): Renamed the second occurrence to "Computed Base Regen" to distinguish it from the base value.

All 917 tests pass.

Fixed three floating point display issues: 1) Elemental Mana Pools (ElementStatsSection.tsx): Raw state.current/state.max values now formatted with fmtDec(state.current, 2) / fmtDec(state.max, 0) to show clean 2-decimal values. 2) Debug Time display (GameStateDebug.tsx): Hour value now displayed with hour.toFixed(2) instead of raw float. 3) Duplicate "Base Regen" label (ManaStatsSection.tsx): Renamed the second occurrence to "Computed Base Regen" to distinguish it from the base value. All 917 tests pass.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#196