Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 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 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 3243 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 3246 of file z3py.py.

3247  def as_long(self):
3248  """Return a Z3 bit-vector numeral as a Python long (bignum) numeral.
3249 
3250  >>> v = BitVecVal(0xbadc0de, 32)
3251  >>> v
3252  195936478
3253  >>> print "0x%.8x" % v.as_long()
3254  0x0badc0de
3255  """
3256  return long(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()
-4L
>>> BitVecVal(7, 3).as_signed_long()
-1L
>>> BitVecVal(3, 3).as_signed_long()
3L
>>> BitVecVal(2L**32 - 1, 32).as_signed_long()
-1L
>>> BitVecVal(2L**64 - 1, 64).as_signed_long()
-1L

Definition at line 3257 of file z3py.py.

3258  def as_signed_long(self):
3259  """Return a Z3 bit-vector numeral as a Python long (bignum) numeral. The most significant bit is assumed to be the sign.
3260 
3261  >>> BitVecVal(4, 3).as_signed_long()
3262  -4L
3263  >>> BitVecVal(7, 3).as_signed_long()
3264  -1L
3265  >>> BitVecVal(3, 3).as_signed_long()
3266  3L
3267  >>> BitVecVal(2L**32 - 1, 32).as_signed_long()
3268  -1L
3269  >>> BitVecVal(2L**64 - 1, 64).as_signed_long()
3270  -1L
3271  """
3272  sz = long(self.size())
3273  val = self.as_long()
3274  if val >= 2L**(sz - 1):
3275  val = val - 2L**sz
3276  if val < -2L**(sz - 1):
3277  val = val + 2L**sz
3278  return val
def as_string (   self)

Definition at line 3279 of file z3py.py.

Referenced by BitVecNumRef.as_long().

3280  def as_string(self):
3281  return Z3_get_numeral_string(self.ctx_ref(), self.as_ast())