Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions
BitVecNumRef Class Reference
+ Inheritance diagram for BitVecNumRef:

Public Member Functions

def as_long
 
def as_signed_long
 
def as_string
 
- Public Member Functions inherited from BitVecRef
def sort
 
def size
 
def __add__
 
def __radd__
 
def __mul__
 
def __rmul__
 
def __sub__
 
def __rsub__
 
def __or__
 
def __ror__
 
def __and__
 
def __rand__
 
def __xor__
 
def __rxor__
 
def __pos__
 
def __neg__
 
def __invert__
 
def __div__
 
def __truediv__
 
def __rdiv__
 
def __rtruediv__
 
def __mod__
 
def __rmod__
 
def __le__
 
def __lt__
 
def __gt__
 
def __ge__
 
def __rshift__
 
def __lshift__
 
def __rrshift__
 
def __rlshift__
 
- Public Member Functions inherited from ExprRef
def as_ast
 
def get_id
 
def sort
 
def sort_kind
 
def __eq__
 
def __ne__
 
def decl
 
def num_args
 
def arg
 
def children
 
- Public Member Functions inherited from AstRef
def __init__
 
def __del__
 
def __str__
 
def __repr__
 
def sexpr
 
def as_ast
 
def get_id
 
def ctx_ref
 
def eq
 
def translate
 
def hash
 
- Public Member Functions inherited from Z3PPObject
def use_pp
 

Additional Inherited Members

- Data Fields inherited from AstRef
 ast
 
 ctx
 

Detailed Description

Bit-vector values.

Definition at line 3351 of file z3py.py.

Member Function Documentation

def as_long (   self)
Return a Z3 bit-vector numeral as a Python long (bignum) numeral. 

>>> v = BitVecVal(0xbadc0de, 32)
>>> v
195936478
>>> print("0x%.8x" % v.as_long())
0x0badc0de

Definition at line 3354 of file z3py.py.

3355  def as_long(self):
3356  """Return a Z3 bit-vector numeral as a Python long (bignum) numeral.
3357 
3358  >>> v = BitVecVal(0xbadc0de, 32)
3359  >>> v
3360  195936478
3361  >>> print("0x%.8x" % v.as_long())
3362  0x0badc0de
3363  """
3364  return int(self.as_string())
def as_signed_long (   self)
Return a Z3 bit-vector numeral as a Python long (bignum) numeral. The most significant bit is assumed to be the sign.

>>> BitVecVal(4, 3).as_signed_long()
-4
>>> BitVecVal(7, 3).as_signed_long()
-1
>>> BitVecVal(3, 3).as_signed_long()
3
>>> BitVecVal(2**32 - 1, 32).as_signed_long()
-1
>>> BitVecVal(2**64 - 1, 64).as_signed_long()
-1

Definition at line 3365 of file z3py.py.

3366  def as_signed_long(self):
3367  """Return a Z3 bit-vector numeral as a Python long (bignum) numeral. The most significant bit is assumed to be the sign.
3368 
3369  >>> BitVecVal(4, 3).as_signed_long()
3370  -4
3371  >>> BitVecVal(7, 3).as_signed_long()
3372  -1
3373  >>> BitVecVal(3, 3).as_signed_long()
3374  3
3375  >>> BitVecVal(2**32 - 1, 32).as_signed_long()
3376  -1
3377  >>> BitVecVal(2**64 - 1, 64).as_signed_long()
3378  -1
3379  """
3380  sz = self.size()
3381  val = self.as_long()
3382  if val >= 2**(sz - 1):
3383  val = val - 2**sz
3384  if val < -2**(sz - 1):
3385  val = val + 2**sz
3386  return int(val)
def as_signed_long
Definition: z3py.py:3365
def as_string (   self)

Definition at line 3387 of file z3py.py.

Referenced by BitVecNumRef.as_long().

3388  def as_string(self):
3389  return Z3_get_numeral_string(self.ctx_ref(), self.as_ast())
def as_ast
Definition: z3py.py:296
Z3_string Z3_API Z3_get_numeral_string(__in Z3_context c, __in Z3_ast a)
Return numeral value, as a string of a numeric constant term.
def ctx_ref
Definition: z3py.py:305