Segmentspan

Original examples

See what joins.
See what stays separate.

These pairs are continuous and closed. Use the same coordinate unit throughout a calculation and enter no header.

Overlap and a real gap

0,4
2,6
9,12

The first two merge to [0,6]; [9,12] remains separate. Raw lengths4+4+3 sum to11, covered lengths6+3 sum to9 and excess is2. A containing [0,12] would incorrectly fill the gap from6 to9.

Touching endpoints

1,2
2,3

The included join2 makes one component [1,3]. Raw and covered lengths both equal2; excess is zero. No extra unit is added for the endpoint.

A nested segment across zero

-3,4
-1,2

The inner segment is contained in [-3,4], whose length is7. Raw length is7+3=10 and excess is3. Negative coordinates do not imply negative length: accepted starts never exceed ends.

Triple duplicates

0,2
0,2
0,2

One component [0,2] remains. Raw length is6, covered length2 and multiplicity excess4. The region covered at least twice has length2, which differs from excess4. This is why the result has a precise label.

Two isolated points

1,1
3,3

Both rows have zero length, yet the union retains two components [1,1] and [3,3]. All three length totals are zero. Zero length does not mean the represented set is empty.

A point at the join

0,1
1,1
1,2

The point1 is already included in the joined [0,2]. Raw and covered lengths are2, with zero excess. The point adds membership but no length.

A one-trillionth gap

0,1
1.000000000001,2

Two components remain. Coverage is1.999999999999. The second start is not rounded to1, and the positive gap is not snapped shut.

A one-trillionth overlap

0,1.000000000001
1,2

The union is [0,2], covered length2. Raw length is2.000000000001, so excess is0.000000000001. Exact arithmetic keeps this accepted overlap visible.

An unsorted chain

5,7
1,3
2,6
1,3

These merge to [1,7], length6. Raw length2+2+4+2 is10, giving excess4. Row order does not affect these totals. Removing the duplicate changes raw sum/excess but leaves the union unchanged.

A bad pair stops success

4,2 is reversed; 0,1,2 has an extra field; 0, has a missing end. An interior blank row is also an error. The calculator rejects rather than silently swapping, dropping or normalizing these rows. Read the method or return to Segmentspan.