Z3
Loading...
Searching...
No Matches
FPNumRef Class Reference
Inheritance diagram for FPNumRef:

Public Member Functions

 sign (self)
 sign_as_bv (self)
 significand (self)
 significand_as_long (self)
 significand_as_bv (self)
 exponent (self, biased=True)
 exponent_as_long (self, biased=True)
 exponent_as_bv (self, biased=True)
 isNaN (self)
 isInf (self)
 isZero (self)
 isNormal (self)
 isSubnormal (self)
 isPositive (self)
 isNegative (self)
 as_string (self)
 py_value (self)
Public Member Functions inherited from FPRef
 sort (self)
 ebits (self)
 sbits (self)
 __le__ (self, other)
 __lt__ (self, other)
 __ge__ (self, other)
 __gt__ (self, other)
 __add__ (self, other)
 __radd__ (self, other)
 __sub__ (self, other)
 __rsub__ (self, other)
 __mul__ (self, other)
 __rmul__ (self, other)
 __pos__ (self)
 __neg__ (self)
 __div__ (self, other)
 __rdiv__ (self, other)
 __truediv__ (self, other)
 __rtruediv__ (self, other)
 __mod__ (self, other)
 __rmod__ (self, other)
Public Member Functions inherited from ExprRef
 as_ast (self)
 get_id (self)
 sort_kind (self)
 __eq__ (self, other)
 __hash__ (self)
 __ne__ (self, other)
 params (self)
 decl (self)
 kind (self)
 num_args (self)
 arg (self, idx)
 children (self)
 update (self, *args)
 from_string (self, s)
 serialize (self)
Public Member Functions inherited from AstRef
 __init__ (self, ast, ctx=None)
 __del__ (self)
 __deepcopy__ (self, memo={})
 __str__ (self)
 __repr__ (self)
 __eq__ (self, other)
 __hash__ (self)
 __nonzero__ (self)
 __bool__ (self)
 sexpr (self)
 ctx_ref (self)
 eq (self, other)
 translate (self, target)
 __copy__ (self)
 hash (self)
Public Member Functions inherited from Z3PPObject
 use_pp (self)

Additional Inherited Members

Data Fields inherited from AstRef
 ast = ast
 ctx = _get_ctx(ctx)
Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)

Detailed Description

The sign of the numeral.

>>> x = FPVal(+1.0, FPSort(8, 24))
>>> x.sign()
False
>>> x = FPVal(-1.0, FPSort(8, 24))
>>> x.sign()
True

Definition at line 10538 of file z3py.py.

Member Function Documentation

◆ as_string()

as_string ( self)
Return a Z3 floating point expression as a Python string.

Reimplemented from FPRef.

Definition at line 10669 of file z3py.py.

10669 def as_string(self):
10670 s = Z3_get_numeral_string(self.ctx.ref(), self.as_ast())
10671 return ("FPVal(%s, %s)" % (s, self.sort()))
10672
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.

◆ exponent()

exponent ( self,
biased = True )

Definition at line 10602 of file z3py.py.

10602 def exponent(self, biased=True):
10603 return Z3_fpa_get_numeral_exponent_string(self.ctx.ref(), self.as_ast(), biased)
10604
Z3_string Z3_API Z3_fpa_get_numeral_exponent_string(Z3_context c, Z3_ast t, bool biased)
Return the exponent value of a floating-point numeral as a string.

◆ exponent_as_bv()

exponent_as_bv ( self,
biased = True )

Definition at line 10623 of file z3py.py.

10623 def exponent_as_bv(self, biased=True):
10624 return BitVecNumRef(Z3_fpa_get_numeral_exponent_bv(self.ctx.ref(), self.as_ast(), biased), self.ctx)
10625
Z3_ast Z3_API Z3_fpa_get_numeral_exponent_bv(Z3_context c, Z3_ast t, bool biased)
Retrieves the exponent of a floating-point literal as a bit-vector expression.

◆ exponent_as_long()

exponent_as_long ( self,
biased = True )

Definition at line 10612 of file z3py.py.

10612 def exponent_as_long(self, biased=True):
10613 ptr = (ctypes.c_longlong * 1)()
10614 if not Z3_fpa_get_numeral_exponent_int64(self.ctx.ref(), self.as_ast(), ptr, biased):
10615 raise Z3Exception("error retrieving the exponent of a numeral.")
10616 return ptr[0]
10617
bool Z3_API Z3_fpa_get_numeral_exponent_int64(Z3_context c, Z3_ast t, int64_t *n, bool biased)
Return the exponent value of a floating-point numeral as a signed 64-bit integer.

◆ isInf()

isInf ( self)

Definition at line 10633 of file z3py.py.

10633 def isInf(self):
10634 return Z3_fpa_is_numeral_inf(self.ctx.ref(), self.as_ast())
10635
bool Z3_API Z3_fpa_is_numeral_inf(Z3_context c, Z3_ast t)
Checks whether a given floating-point numeral is a +oo or -oo.

◆ isNaN()

isNaN ( self)

Definition at line 10628 of file z3py.py.

10628 def isNaN(self):
10629 return Z3_fpa_is_numeral_nan(self.ctx.ref(), self.as_ast())
10630
bool Z3_API Z3_fpa_is_numeral_nan(Z3_context c, Z3_ast t)
Checks whether a given floating-point numeral is a NaN.

◆ isNegative()

isNegative ( self)

Definition at line 10658 of file z3py.py.

10658 def isNegative(self):
10659 return Z3_fpa_is_numeral_negative(self.ctx.ref(), self.as_ast())
10660
bool Z3_API Z3_fpa_is_numeral_negative(Z3_context c, Z3_ast t)
Checks whether a given floating-point numeral is negative.

◆ isNormal()

isNormal ( self)

Definition at line 10643 of file z3py.py.

10643 def isNormal(self):
10644 return Z3_fpa_is_numeral_normal(self.ctx.ref(), self.as_ast())
10645
bool Z3_API Z3_fpa_is_numeral_normal(Z3_context c, Z3_ast t)
Checks whether a given floating-point numeral is normal.

◆ isPositive()

isPositive ( self)

Definition at line 10653 of file z3py.py.

10653 def isPositive(self):
10654 return Z3_fpa_is_numeral_positive(self.ctx.ref(), self.as_ast())
10655
bool Z3_API Z3_fpa_is_numeral_positive(Z3_context c, Z3_ast t)
Checks whether a given floating-point numeral is positive.

◆ isSubnormal()

isSubnormal ( self)

Definition at line 10648 of file z3py.py.

10648 def isSubnormal(self):
10649 return Z3_fpa_is_numeral_subnormal(self.ctx.ref(), self.as_ast())
10650
bool Z3_API Z3_fpa_is_numeral_subnormal(Z3_context c, Z3_ast t)
Checks whether a given floating-point numeral is subnormal.

◆ isZero()

isZero ( self)

Definition at line 10638 of file z3py.py.

10638 def isZero(self):
10639 return Z3_fpa_is_numeral_zero(self.ctx.ref(), self.as_ast())
10640
bool Z3_API Z3_fpa_is_numeral_zero(Z3_context c, Z3_ast t)
Checks whether a given floating-point numeral is +zero or -zero.

◆ py_value()

py_value ( self)
Return a Python value that is equivalent to `self`.

Reimplemented from AstRef.

Definition at line 10673 of file z3py.py.

10673 def py_value(self):
10674 bv = simplify(fpToIEEEBV(self))
10675 binary = bv.py_value()
10676 if not isinstance(binary, int):
10677 return None
10678 # Decode the IEEE 754 binary representation
10679 import struct
10680 bytes_rep = binary.to_bytes(8, byteorder='big')
10681 return struct.unpack('>d', bytes_rep)[0]
10682
10683

◆ sign()

sign ( self)

Definition at line 10549 of file z3py.py.

10549 def sign(self):
10550 num = ctypes.c_bool()
10551 nsign = Z3_fpa_get_numeral_sign(self.ctx.ref(), self.as_ast(), byref(num))
10552 if nsign is False:
10553 raise Z3Exception("error retrieving the sign of a numeral.")
10554 return num.value != 0
10555

◆ sign_as_bv()

sign_as_bv ( self)

Definition at line 10561 of file z3py.py.

10561 def sign_as_bv(self):
10562 return BitVecNumRef(Z3_fpa_get_numeral_sign_bv(self.ctx.ref(), self.as_ast()), self.ctx)
10563
Z3_ast Z3_API Z3_fpa_get_numeral_sign_bv(Z3_context c, Z3_ast t)
Retrieves the sign of a floating-point literal as a bit-vector expression.

◆ significand()

significand ( self)

Definition at line 10571 of file z3py.py.

10571 def significand(self):
10572 return Z3_fpa_get_numeral_significand_string(self.ctx.ref(), self.as_ast())
10573
Z3_string Z3_API Z3_fpa_get_numeral_significand_string(Z3_context c, Z3_ast t)
Retrieves the sign of a floating-point literal.

◆ significand_as_bv()

significand_as_bv ( self)

Definition at line 10592 of file z3py.py.

10592 def significand_as_bv(self):
10593 return BitVecNumRef(Z3_fpa_get_numeral_significand_bv(self.ctx.ref(), self.as_ast()), self.ctx)
10594
Z3_ast Z3_API Z3_fpa_get_numeral_significand_bv(Z3_context c, Z3_ast t)
Retrieves the significand of a floating-point literal as a bit-vector expression.

◆ significand_as_long()

significand_as_long ( self)

Definition at line 10581 of file z3py.py.

10581 def significand_as_long(self):
10582 ptr = (ctypes.c_ulonglong * 1)()
10583 if not Z3_fpa_get_numeral_significand_uint64(self.ctx.ref(), self.as_ast(), ptr):
10584 raise Z3Exception("error retrieving the significand of a numeral.")
10585 return ptr[0]
10586
bool Z3_API Z3_fpa_get_numeral_significand_uint64(Z3_context c, Z3_ast t, uint64_t *n)
Return the significand value of a floating-point numeral as a uint64.