various: eliminate floating-point noise before displaying

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ic14f4c0a9e0bcbe3460bbecc670f713d6a6a6964
This commit is contained in:
raf 2026-04-14 14:59:46 +03:00
commit d26a70dacd
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
3 changed files with 16 additions and 6 deletions

View file

@ -303,7 +303,13 @@ const ComparisonView: Component<ComparisonViewProps> = props => {
<Show when={!row.isReduction}>
<ArrowUpIcon size={14} />
</Show>
{Math.abs(row.change).toFixed(prec())}%
{parseFloat(
(
Math.round(Math.abs(row.change) * Math.pow(10, prec())) /
Math.pow(10, prec())
).toFixed(prec()),
)}
%
</span>
</Show>
}

View file

@ -49,7 +49,10 @@ const ThunkChart: Component<ThunkChartProps> = props => {
<div class="ratio-bar">
<div class="ratio-fill" style={{ width: `${avoidedRatio() * 100}%` }} />
</div>
<span class="ratio-label">Avoidance rate: {(avoidedRatio() * 100).toFixed(prec())}%</span>
<span class="ratio-label">
Avoidance rate:{' '}
{Math.round(avoidedRatio() * 100 * Math.pow(10, prec())) / Math.pow(10, prec())}%
</span>
</div>
</div>
);