mirror of
https://github.com/Z3Prover/z3
synced 2025-08-04 18:30:24 +00:00
deal with unsigned / bignum #4361
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
78a4717c06
commit
1072bf1536
2 changed files with 30 additions and 13 deletions
|
@ -417,18 +417,25 @@ public:
|
|||
|
||||
static bool is_rational() { return true; }
|
||||
|
||||
unsigned get_num_bits() const {
|
||||
rational two(2);
|
||||
unsigned get_num_digits(rational const& base) const {
|
||||
SASSERT(is_int());
|
||||
SASSERT(!is_neg());
|
||||
rational n(*this);
|
||||
unsigned num_bits = 1;
|
||||
n = div(n, two);
|
||||
unsigned num_digits = 1;
|
||||
n = div(n, base);
|
||||
while (n.is_pos()) {
|
||||
++num_bits;
|
||||
n = div(n, two);
|
||||
++num_digits;
|
||||
n = div(n, base);
|
||||
}
|
||||
return num_bits;
|
||||
return num_digits;
|
||||
}
|
||||
|
||||
unsigned get_num_bits() const {
|
||||
return get_num_digits(rational(2));
|
||||
}
|
||||
|
||||
unsigned get_num_decimal() const {
|
||||
return get_num_digits(rational(10));
|
||||
}
|
||||
|
||||
static bool limit_denominator(rational &num, rational const& limit);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue