56 for(std::size_t i=0; i<
n.size(); i++)
57 if(!(
isalnum(
n[i]) || (
n[i]==
'-' && i==0)))
71 bool neg=
a.is_negative();
79 std::size_t len =
a.digits(2) + 2;
80 std::vector<char> buffer(len);
81 char *s =
a.as_string(buffer.data(), len, 2);
83 std::string result(s);
85 if(result.size()<width)
88 fill.resize(width-result.size(),
'0');
91 else if(result.size()>width)
92 result=result.substr(result.size()-width, width);
96 for(std::size_t i=0; i<result.size(); i++)
97 result[i]=(result[i]==
'0')?
'1':
'0';
105 unsigned len =
n.digits(base) + 2;
106 std::vector<char> buffer(len);
107 char *s =
n.as_string(buffer.data(), len, base);
109 std::string result(s);
122 if(
n.size() <= (
sizeof(
unsigned long) *
CHAR_BIT))
126 unsigned long mask=1;
127 mask=mask << (
n.size()-1);
134 for(std::string::const_iterator it=++
n.begin();
152 mask=mask << (
n.size()-1);
158 for(std::string::const_iterator it=++
n.begin();
171 if(
n.find_first_not_of(
"01")!=std::string::npos)
193 std::function<
bool(
bool,
bool)> f)
195 const auto digits = std::max(
a.digits(2),
b.digits(2));
200 for(std::size_t i = 0; i <
digits; i++)
206 result +=
power(2, i);
220 if(
a.is_ulong() &&
b.is_ulong())
221 return a.to_ulong() |
b.to_ulong();
232 if(
a.is_ulong() &&
b.is_ulong())
233 return a.to_ulong() &
b.to_ulong();
244 if(
a.is_ulong() &&
b.is_ulong())
245 return a.to_ulong() ^
b.to_ulong();
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
const mp_integer binary2integer(const std::string &n, bool is_signed)
convert binary string representation to mp_integer
const mp_integer string2integer(const std::string &n, unsigned base)
BigInt::ullong_t ullong_t
mp_integer logic_right_shift(const mp_integer &a, const mp_integer &b, std::size_t true_size)
logic right shift (loads 0 on MSB) bitwise operations only make sense on native objects,...
mp_integer operator>>(const mp_integer &a, const mp_integer &b)
mp_integer arith_left_shift(const mp_integer &a, const mp_integer &b, std::size_t true_size)
arithmetic left shift bitwise operations only make sense on native objects, hence the largest object ...
mp_integer arith_right_shift(const mp_integer &a, const mp_integer &b, std::size_t true_size)
arithmetic right shift (loads sign on MSB) bitwise operations only make sense on native objects,...
mp_integer logic_left_shift(const mp_integer &a, const mp_integer &b, std::size_t true_size)
logic left shift bitwise operations only make sense on native objects, hence the largest object size ...
mp_integer rotate_right(const mp_integer &a, const mp_integer &b, std::size_t true_size)
rotates right (MSB=LSB) bitwise operations only make sense on native objects, hence the largest objec...
const std::string integer2string(const mp_integer &n, unsigned base)
mp_integer bitwise_and(const mp_integer &a, const mp_integer &b)
bitwise 'and' of two nonnegative integers
mp_integer bitwise_or(const mp_integer &a, const mp_integer &b)
bitwise 'or' of two nonnegative integers
mp_integer bitwise_xor(const mp_integer &a, const mp_integer &b)
bitwise 'xor' of two nonnegative integers
mp_integer operator<<(const mp_integer &a, const mp_integer &b)
mp_integer bitwise(const mp_integer &a, const mp_integer &b, std::function< bool(bool, bool)> f)
bitwise binary operation over two integers, given as a functor
mp_integer rotate_left(const mp_integer &a, const mp_integer &b, std::size_t true_size)
rotate left (LSB=MSB) bitwise operations only make sense on native objects, hence the largest object ...
const std::string integer2binary(const mp_integer &n, std::size_t width)
static struct_typet::componentst::iterator pad(struct_typet::componentst &components, struct_typet::componentst::iterator where, std::size_t pad_bits)
#define PRECONDITION(CONDITION)
bool is_signed(const typet &t)
Convenience function – is the type signed?