3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-28 11:25:51 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-05-13 17:23:55 -07:00
parent cf8b3a0788
commit 49a903c875
3 changed files with 16 additions and 5 deletions

View file

@ -61,6 +61,7 @@ public:
if (is_free()) return out << "free";
return out << "[" << pp(lo) << ", " << pp(hi) << "[";
}
Numeral closest_value(Numeral const& n) const;
};
template<typename Numeral>

View file

@ -109,3 +109,14 @@ mod_interval<Numeral> mod_interval<Numeral>::operator&(mod_interval const& other
return mod_interval::empty();
return mod_interval(l, h);
}
template<typename Numeral>
Numeral mod_interval<Numeral>::closest_value(Numeral const& n) const {
if (contains(n))
return n;
if (is_empty())
return n;
if (lo - n < n - hi)
return lo;
return hi - 1;
}