class Z3::FloatSort

Overview

Real IEEE 754 floats, not Reals - Float(11, 53) is a double, with everything that implies: two zeroes, two infinities, NaN, and rounding on every operation.

A sort is its two bit counts, the exponent's and the significand's, and the four IEEE widths can be named instead:

Z3::FloatSort.new(:double)     # also :half, :single, :quadruple
Z3::FloatSort.new(64)          # also 16, 32, 128
Z3::FloatSort.new(11, 53)      # the same sort again

Defined in:

z3/float_sort.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(ebits : Int, sbits : Int) #

[View source]
def self.new(width : Int | Symbol) #

The four IEEE widths, by total size or by name. Each is only its two bit counts, so this is mk_fpa_sort too - Z3's mk_fpa_sort_16 and friends are the same four sorts under their IEEE names.


[View source]

Instance Method Detail

def ==(other : FloatSort) #

Z3 hash-conses its sorts, so two Float sorts of the same two sizes are one sort


[View source]
def [](expr : FloatExpr) #

[View source]
def [](value : Float64) #

A Crystal Float64 is an IEEE double, so every value converts exactly into Float(11, 53) - NaN, the infinities and the two zeroes included - and rounds to nearest into anything narrower.


[View source]
def [](value : Int) #

[View source]
def cast(value) : FloatExpr #

[View source]
def ebits : UInt32 #

[View source]
def from_ast(ast : LibZ3::Ast) : FloatExpr #

[View source]
def from_components(sign : BitvecExpr, exponent : BitvecExpr, significand : BitvecExpr) #

The three IEEE fields separately, which is #sign_bv / #exponent_bv / #significand_bv backwards. The significand excludes the leading bit IEEE doesn't store, so it's one narrower than #sbits.


[View source]
def from_float(float : FloatExpr, mode : RoundingModeExpr) #

[View source]
def from_ieee_bv(bv : BitvecExpr) #

Reinterprets the IEEE 754 bits, so it's FloatExpr#to_ieee_bv backwards and nothing is rounded. The Bitvec has to be exactly as wide as this sort.


[View source]
def from_real(real, mode : RoundingModeExpr) #

[View source]
def from_signed_bv(bv : BitvecExpr, mode : RoundingModeExpr) #

Reads the Bitvec as a number and rounds it to this sort, where #from_ieee_bv reads the very same bits as a float already


[View source]
def from_significand_and_exponent(significand, exponent, mode : RoundingModeExpr) #

significand * 2 ** exponent, with a Real significand and an Int exponent - the one constructor which isn't a conversion from some other representation


[View source]
def from_unsigned_bv(bv : BitvecExpr, mode : RoundingModeExpr) #

[View source]
def nan #

The values IEEE has and no Crystal literal spells. self[Float64::NAN] and friends build the same three, since a Crystal Float64 has them too.


[View source]
def negative_infinity #

[View source]
def negative_zero #

[View source]
def positive_infinity #

[View source]
def positive_zero #

[View source]
def sbits : UInt32 #

[View source]
def to_s(io) #

[View source]
def to_unsafe : LibZ3::Sort #

[View source]
def var(name : String) #

[View source]