Z3 |

Public Member Functions
BitVecNumRef Class Reference
Inheritance diagram for BitVecNumRef:

## Public Member Functions
def | as_long (self)
def | as_signed_long (self)
def | as_string (self)
def | as_binary_string (self)
Public Member Functions inherited from BitVecRef
def | sort (self)
def | size (self)
def | __add__ (self, other)
def | __radd__ (self, other)
def | __mul__ (self, other)
def | __rmul__ (self, other)
def | __sub__ (self, other)
def | __rsub__ (self, other)
def | __or__ (self, other)
def | __ror__ (self, other)
def | __and__ (self, other)
def | __rand__ (self, other)
def | __xor__ (self, other)
def | __rxor__ (self, other)
def | __pos__ (self)
def | __neg__ (self)
def | __invert__ (self)
def | __div__ (self, other)
def | __truediv__ (self, other)
def | __rdiv__ (self, other)
def | __rtruediv__ (self, other)
def | __mod__ (self, other)
def | __rmod__ (self, other)
def | __le__ (self, other)
def | __lt__ (self, other)
def | __gt__ (self, other)
def | __ge__ (self, other)
def | __rshift__ (self, other)
def | __lshift__ (self, other)
def | __rrshift__ (self, other)
def | __rlshift__ (self, other)
Public Member Functions inherited from ExprRef
def | as_ast (self)
def | get_id (self)
def | sort (self)
def | sort_kind (self)
def | __eq__ (self, other)
def | __hash__ (self)
def | __ne__ (self, other)
def | params (self)
def | decl (self)
def | num_args (self)
def | arg (self, idx)
def | children (self)
Public Member Functions inherited from AstRef
def | __init__ (self, ast, ctx=None)
def | __del__ (self)
def | __deepcopy__ (self, memo={})
def | __str__ (self)
def | __repr__ (self)
def | __eq__ (self, other)
def | __hash__ (self)
def | __nonzero__ (self)
def | __bool__ (self)
def | sexpr (self)
def | as_ast (self)
def | get_id (self)
def | ctx_ref (self)
def | eq (self, other)
def | translate (self, target)
def | __copy__ (self)
def | hash (self)
Public Member Functions inherited from Z3PPObject
def | use_pp (self)

## Additional Inherited Members
Data Fields inherited from AstRef
| ast
| ctx

## Detailed Description

    Bit-vector values.

Definition at line 3862 of file z3py.py.

## Member Function Documentation

## ◆ as_binary_string()

def as_binary_string | ( |  | self | ) |

Definition at line 3902 of file z3py.py.

3902 def as_binary_string(self):
3903 return Z3_get_numeral_binary_string(self.ctx_ref(), self.as_ast())
3904
3905
Z3_get_numeral_binary_string
Z3_string Z3_API Z3_get_numeral_binary_string(Z3_context c, Z3_ast a)
Return numeral value, as a binary string of a numeric constant term.

## ◆ as_long()

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 3865 of file z3py.py.

3865 def as_long(self):
3866 """Return a Z3 bit-vector numeral as a Python long (bignum) numeral.
3867
3868 >>> v = BitVecVal(0xbadc0de, 32)
3869 >>> v
3870 195936478
3871 >>> print("0x%.8x" % v.as_long())
3872 0x0badc0de
3873 """
3874 return int(self.as_string())
3875
z3py.BitVecVal
def BitVecVal(val, bv, ctx=None)
Definition: z3py.py:3982

Referenced by BitVecNumRef.as_signed_long().

## ◆ as_signed_long()

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 3876 of file z3py.py.

3876 def as_signed_long(self):
3877 """Return a Z3 bit-vector numeral as a Python long (bignum) numeral.
3878 The most significant bit is assumed to be the sign.
3879
3880 >>> BitVecVal(4, 3).as_signed_long()
3881 -4
3882 >>> BitVecVal(7, 3).as_signed_long()
3883 -1
3884 >>> BitVecVal(3, 3).as_signed_long()
3885 3
3886 >>> BitVecVal(2**32 - 1, 32).as_signed_long()
3887 -1
3888 >>> BitVecVal(2**64 - 1, 64).as_signed_long()
3889 -1
3890 """
3891 sz = self.size()
3892 val = self.as_long()
3893 if val >= 2**(sz - 1):
3894 val = val - 2**sz
3895 if val < -2**(sz - 1):
3896 val = val + 2**sz
3897 return int(val)
3898

Referenced by BitVecNumRef.as_signed_long().

## ◆ as_string()

def as_string | ( |  | self | ) |

Definition at line 3899 of file z3py.py.

3899 def as_string(self):
3900 return Z3_get_numeral_string(self.ctx_ref(), self.as_ast())
3901
Z3_get_numeral_string
Z3_string Z3_API Z3_get_numeral_string(Z3_context c, Z3_ast a)
Return numeral value, as a decimal string of a numeric constant term.

Referenced by IntNumRef.as_long(), BitVecNumRef.as_long(), and FiniteDomainNumRef.as_long().