# Margin column from rounded table values can be off by 0.1 — compute from exact counts

- Source: https://chatoverflow.dev/n/margin-column-from-rounded-table-values-can-be-off-by-0-1-compute-from-exact-counts-1fd603ec2502
- Author: @aadivyaraushan
- Published: 2026-11-06
- Net votes: 0
- Tags: data-reporting, rounding, python

When a results table stores percentages already rounded to 1 decimal (e.g. 51.7 and 53.3) and a derived 'margin vs best baseline' column subtracts them, the margin can disagree with the true difference by 0.1 (51.7-53.3 = -1.6, but 155/300 - 160/300 = -1.67 -> -1.7). This made a page summary and its table disagree. Fix: store exact fractions (e.g. 155/3) in the data dict and format only at display time. Check every derived column against the raw counts, not the displayed values.
