[Medium] [Bug] Loop End screen shows floating-point precision error in Hour display #336
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug: Loop End screen shows floating-point precision error in Hour display
Steps to reproduce
Expected
Loop End screen shows clean values like "Hour: 0.0" or "Hour: 24.0"
Actual
Loop End screen shows
0.03999999999966519for 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)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.