mirror of
https://github.com/Z3Prover/z3
synced 2025-04-29 20:05:51 +00:00
Reorganizing source code. Created util dir
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
630ba0c675
commit
2c464d413d
153 changed files with 0 additions and 0 deletions
|
@ -1,61 +0,0 @@
|
|||
/*++
|
||||
Copyright (c) 2007 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
approx_nat.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
Approximated natural numbers. It performs operations on the set [0, ..., 2^{n-2}, huge].
|
||||
Where huge represents all numbers greater than 2^{n-2}.
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2008-01-11
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#include"approx_nat.h"
|
||||
|
||||
approx_nat::approx_nat(unsigned val) {
|
||||
m_value = val > m_limit ? UINT_MAX : val;
|
||||
}
|
||||
|
||||
approx_nat & approx_nat::operator=(unsigned val) {
|
||||
m_value = val > m_limit ? UINT_MAX : val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
approx_nat & approx_nat::operator+=(unsigned w) {
|
||||
if (is_huge())
|
||||
return *this;
|
||||
if (w > m_limit) {
|
||||
m_value = UINT_MAX;
|
||||
return *this;
|
||||
}
|
||||
m_value += w;
|
||||
if (m_value > m_limit)
|
||||
m_value = UINT_MAX;
|
||||
return *this;
|
||||
}
|
||||
|
||||
approx_nat & approx_nat::operator*=(unsigned w) {
|
||||
if (is_huge())
|
||||
return *this;
|
||||
unsigned long long r = static_cast<unsigned long long>(m_value) * static_cast<unsigned long long>(w);
|
||||
if (r > m_limit)
|
||||
m_value = UINT_MAX;
|
||||
else
|
||||
m_value = static_cast<unsigned>(r);
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::ostream & operator<<(std::ostream & target, approx_nat const & w) {
|
||||
if (w.is_huge())
|
||||
target << "[huge]";
|
||||
else
|
||||
target << w.get_value();
|
||||
return target;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue