DfDoubleRangeType (double from, double to, boolean exact) { if (Double.compare(from, to) > 0) return this; if (myInvert) { if (Double.compare(to, myFrom) < 0 || Double.compare(from, myTo) > 0) return this; int fromCmp = Double.compare(myFrom, from); int toCmp = Double.compare(to, myTo); if (fromCmp >= 0 && toCmp >= 0 || fromCmp < 0 && toCmp < 0) { return exact ? null : (DfDoubleRangeType)create(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false, myNaN); } if (fromCmp >= 0) { return (DfDoubleRangeType)create(nextUp(to), myTo, true, myNaN); } return (DfDoubleRangeType)create(myFrom, nextDown(from), true, myNaN); } else { if (Double.compare(myTo, nextDown(from)) < 0 || Double.compare(to, nextDown(myFrom)) < 0) { if (myFrom == Double.NEGATIVE_INFINITY && to == Double.POSITIVE_INFINITY) { return (DfDoubleRangeType)create(nextUp(myTo), nextDown(from), true, myNaN); } if (exact) return null; } return (DfDoubleRangeType)create(Math.min(myFrom, from), Math.max(myTo, to), false, myNaN); } }