toDoubleLength method

double toDoubleLength()

Returns the length an Interval as double.

Returns 0.0 if the interval is empty or contains a single value. Returns double.infinity if one of the bounds is unbounded (infinite).

Implementation

double toDoubleLength() {
  if (isEmpty || isSingle) {
    return 0.0;
  } else if (lower.isUnbounded || upper.isUnbounded) {
    return double.infinity;
  } else {
    return upper.endpoint.toDouble() - lower.endpoint.toDouble();
  }
}