A closed real interval [lo, hi] whose endpoints are rigorous bounds (F_0008).
The answer to the accuracy question the exact tier does not ask: what a computation's result can be, given that its inputs are only known to lie in ranges. Every operation returns an interval guaranteed to contain every value the operation can take on its operands — the containment property — by rounding each endpoint outward.
The first sibling of _Number that deliberately does NOT widen (Decision A). _Rational and _Based read as numbers through _Number's widening extractor (_Complex and _Truth are siblings that do not); an interval must not, because one read as a single Double would silently become one endpoint — the worst failure this library has. So every case _Number(x) site simply does not match an interval, and every pass without an interval rule leaves the expression symbolic by construction. Intervals are results of evaluation; they are not operands of symbolic algebra (F_0014 is that).
The endpoint type chooses the bounds (Decision B): two _Rational endpoints are an exact interval, combined exactly and bounded through spire at the working precision where an operation leaves the rationals; Double endpoints are combined in IEEE-754 and rounded outward. Mixing the two demotes, outward — float contagion, as everywhere.
Rounding, stated because it is where interval code goes wrong: + − × ÷ and the square root detect an exact Double result with error-free transformations and widen by one ulp only on an inexact side, so [1, 2] − [1, 2] is exactly [−1, 1]. A transcendental is widened by two ulps on both platforms, since ECMAScript does not specify the accuracy of Math.sin the way the JDK does — one figure everywhere, never a platform branch. A value known exactly (exp(0) = 1) is not widened.
Endpoints are finite: a half-infinite interval is declined, not handled. lo == hi collapses to the number itself. Built only through _Interval.of.
Renders [lo, hi] at precision decimals, rounded outward: the lower end down and the upper end up, so the displayed interval still contains the computed one. An exact endpoint that prints as a short fraction is shown as that fraction, unrounded.
Renders [lo, hi] at precision decimals, rounded outward: the lower end down and the upper end up, so the displayed interval still contains the computed one. An exact endpoint that prints as a short fraction is shown as that fraction, unrounded.
It is reflexive: for any instance x of type Any, x.equals(x) should return true.
It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).
Value parameters
that
the object to compare against this object for equality.
Attributes
Returns
true if the receiver object is equivalent to the argument; false otherwise.
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.
Not lossless, unlike most values' toString: parsing it back gives a wider interval, never a narrower one, so containment survives but the endpoints do not — the _Rational.toString precedent, whose decimal fallback is also a display form. :save writes the endpoints in full instead (the REPL's serializeValue); the simplify command and an _IntervalOf over interval children print this rounded form.