[Medium] [Bug] Loop End screen shows floating-point precision error in Hour display #336

Open
opened 2026-06-09 12:50:55 +02:00 by Anexim · 2 comments
Owner

Bug: Loop End screen shows floating-point precision error in Hour display

Steps to reproduce

  1. Open the game
  2. Go to Debug tab → Game State
  3. Click "Day 30"
  4. Wait for the loop to end (game-over triggers)

Expected

Loop End screen shows clean values like "Hour: 0.0" or "Hour: 24.0"

Actual

Loop End screen shows 0.03999999999966519 for the Hour value — a floating-point precision artifact.

Root cause

The hour value is accumulated via repeated addition of HOURS_PER_TICK (0.04) without rounding. Over many ticks, floating-point errors accumulate. The value should be rounded before display.

Store

useGameStoregameStore.ts → tick pipeline (hour accumulation)

## Bug: Loop End screen shows floating-point precision error in Hour display ### Steps to reproduce 1. Open the game 2. Go to Debug tab → Game State 3. Click "Day 30" 4. Wait for the loop to end (game-over triggers) ### Expected Loop End screen shows clean values like "Hour: 0.0" or "Hour: 24.0" ### Actual Loop End screen shows `0.03999999999966519` for the Hour value — a floating-point precision artifact. ### Root cause The hour value is accumulated via repeated addition of `HOURS_PER_TICK` (0.04) without rounding. Over many ticks, floating-point errors accumulate. The value should be rounded before display. ### Store `useGameStore` → `gameStore.ts` → tick pipeline (hour accumulation)
Anexim added the ai:todo label 2026-06-09 12:50:55 +02:00
n8n-gitea was assigned by Anexim 2026-06-09 12:50:55 +02:00
Author
Owner

Note for implementer: This is purely a display rounding issue. The underlying value is correct (≈0.04 hours = 1 tick past the day boundary). The fix is simply to format the Hour value with fmt() like the other fields in the same grid, or round to 2 decimal places. No logic change needed.

**Note for implementer:** This is purely a display rounding issue. The underlying value is correct (≈0.04 hours = 1 tick past the day boundary). The fix is simply to format the Hour value with `fmt()` like the other fields in the same grid, or round to 2 decimal places. No logic change needed.
Author
Owner

Note for implementer: This is purely a display rounding issue. The underlying value is correct (≈0.04 hours = 1 tick past the day boundary). The fix is simply to format the Hour value with fmt() like the other fields in the same grid, or round to 2 decimal places. No logic change needed.

**Note for implementer:** This is purely a display rounding issue. The underlying value is correct (≈0.04 hours = 1 tick past the day boundary). The fix is simply to format the Hour value with `fmt()` like the other fields in the same grid, or round to 2 decimal places. No logic change needed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#336