Some background first perhaps:
- All arithmetic is done using integers. When non-integral values are needed (e.g. commerce), the value is stored "times 100" to allow for exactly two decimals. This allows faster calculations while allowing for an exact fractional amount.
- All yields food:, , and ) are stored and added up as whole numbers. The only place a fractional yield occurs is in this new feature, and it's only fractional while adding up the trade routes for a single city. The total for a city is rounded as soon as it gets converted into actual (and and , but in BTS the trade route yield modifiers for those yields are both 0%).
The storage and calculation of fractional trade routes aren't the problem; I've completely handled them with no issues. The only issue arrises is when displaying the values to the user
not aggregated city-by-city. When displaying the total trade with a single rival, I must add up a subset of trade route yields across cities. If I do the rounding for each city individually as I would when summing up all trade routes, the lost
will be wrong, producing incorrect totals.
There's absolutely no way to produce correct display totals.
So, what to do given that I have to display slightly incorrect trade totals? My suggestion is to show the unrounded total to indicate that it's approximate, just as the unrounded value is shown when hovering over a single trade route in a city.