Range Algebra for Safe Array Splits
Abstract
We present a language-agnostic range algebra that derives correct index intervals for splitting arrays and implementing binary search, eliminating off-by-one and empty-range bugs. From two primitives -- n/2 and n/2 = (n + 1)/2 -- we obtain four canonical splits (Natural, Left+, Right+, Center-cut) with proofs of coverage and balance for all n 0 and any base index b ∈ Z. We record invariants (normalization to left-closed/right-open intervals [u, w) with len = w - u), document cross-language division quirks, and give drop-in code patterns and property tests. The result is a small, memorable spec that can be copied verbatim into C/C++/Java/C\#/Go/Rust/Swift/JS/Python.
Turn this paper into a lesson
ArcXiv compiles a structured reading guide from this paper's metadata: plain-English importance, contributions, prerequisite concepts, which sections to read first, flashcards, and a quiz. Grounded in the abstract, never invented.