mirror of
https://github.com/Z3Prover/z3
synced 2025-04-25 01:55:32 +00:00
Fix get_int64 and is_int64 methods in mpz. Fix INT64_MAX constant definition.
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
1ef17cbe67
commit
03c1b24dea
3 changed files with 29 additions and 12 deletions
|
@ -211,6 +211,30 @@ class mpz_manager {
|
|||
|
||||
static digit_t * digits(mpz const & c) { return c.m_ptr->m_digits; }
|
||||
|
||||
// Return true if the absolute value fits in a UINT64
|
||||
static bool is_abs_uint64(mpz const & a) {
|
||||
if (is_small(a))
|
||||
return true;
|
||||
if (sizeof(digit_t) == sizeof(uint64))
|
||||
return size(a) <= 1;
|
||||
else
|
||||
return size(a) <= 2;
|
||||
}
|
||||
|
||||
// CAST the absolute value into a UINT64
|
||||
static uint64 big_abs_to_uint64(mpz const & a) {
|
||||
SASSERT(is_abs_uint64(a));
|
||||
SASSERT(!is_small(a));
|
||||
if (a.m_ptr->m_size == 1)
|
||||
return digits(a)[0];
|
||||
if (sizeof(digit_t) == sizeof(uint64))
|
||||
// 64-bit machine
|
||||
return digits(a)[0];
|
||||
else
|
||||
// 32-bit machine
|
||||
return ((static_cast<uint64>(digits(a)[1]) << 32) | (static_cast<uint64>(digits(a)[0])));
|
||||
}
|
||||
|
||||
template<int IDX>
|
||||
void get_sign_cell(mpz const & a, int & sign, mpz_cell * & cell) {
|
||||
if (is_small(a)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue