A common offset for integer rounding #
Signed Euclidean division by a positive integer is floor division. Averaging over all offsets recovers the original integer, and the total rounded absolute difference recovers the original absolute difference. Consequently a family of endpoint differences with total absolute value less than the denominator has an offset that rounds every pair to equal integers.
The endpoint-slope bounds used in finite graph specialization are preserved by this same rounding, including negative heights and negative slopes.
Floor an integer after adding the chosen residue offset.
Equations
- Utilities.CommonOffsetRounding.round N k a = (a + ↑↑k) / ↑N
Instances For
theorem
Utilities.CommonOffsetRounding.exists_common_offset
{ι : Type u_1}
(N : ℕ)
(hN : 0 < N)
(F : Finset ι)
(A B : ι → ℤ)
(hBudget : ∑ e ∈ F, |A e - B e| < ↑N)
:
If the total discrepancy of finitely many endpoint pairs is less than
N, one common residue offset rounds all those pairs to equal integers.