59 if(new_fraction_bits>old_fraction_bits)
60 result=
v*
power(2, new_fraction_bits-old_fraction_bits);
61 else if(new_fraction_bits<old_fraction_bits)
143 if(int_value.is_negative())
149 std::string base_10_string=
152 while(base_10_string.size()<=fraction_bits)
153 base_10_string=
"0"+base_10_string;
155 std::string integer_part=
156 std::string(base_10_string, 0, base_10_string.size()-fraction_bits);
158 std::string fraction_part=
159 std::string(base_10_string, base_10_string.size()-fraction_bits);
164 while(!fraction_part.empty() &&
165 fraction_part[fraction_part.size()-1]==
'0')
166 fraction_part.resize(fraction_part.size()-1);
168 if(!fraction_part.empty())
169 dest+=
"."+fraction_part;
Pre-defined bitvector types.
const fixedbv_typet & to_fixedbv_type(const typet &type)
Cast a typet to a fixedbv_typet.
void set_width(std::size_t width)
std::size_t get_width() const
A constant literal expression.
const irep_idt & get_value() const
typet & type()
Return the type of the expression.
std::size_t get_fraction_bits() const
Fixed-width bit-vector with signed fixed-point interpretation.
void set_integer_bits(std::size_t b)
std::size_t get_integer_bits() const
void from_integer(const mp_integer &i)
void from_expr(const constant_exprt &expr)
bool operator==(int i) const
fixedbvt & operator+=(const fixedbvt &other)
mp_integer to_integer() const
fixedbvt & operator*=(const fixedbvt &other)
void round(const fixedbv_spect &dest_spec)
std::string format(const format_spect &format_spec) const
fixedbvt & operator/=(const fixedbvt &other)
fixedbvt & operator-=(const fixedbvt &other)
constant_exprt to_expr() const
const std::string integer2string(const mp_integer &n, unsigned base)
#define PRECONDITION(CONDITION)
API to expression classes.