CBMC
boolbv_floatbv_mod_rem.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #include "boolbv.h"
10 
11 #include <util/bitvector_types.h>
12 
14 
16 {
17  // Note that the expressions do not have rounding modes
18  // but float_utils requires one.
19 
20  float_utilst float_utils(prop);
21 
23  float_utils.set_rounding_mode(rm);
24 
25  float_utils.spec = ieee_float_spect(to_floatbv_type(expr.type()));
26 
27  bvt lhs_as_bv = convert_bv(expr.lhs());
28  bvt rhs_as_bv = convert_bv(expr.rhs());
29 
30  // float_utilst::rem implements lhs-(lhs/rhs)*rhs, which matches
31  // neither fmod() nor IEEE
32  return float_utils.rem(lhs_as_bv, rhs_as_bv);
33 }
Pre-defined bitvector types.
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
A base class for binary expressions.
Definition: std_expr.h:638
exprt & lhs()
Definition: std_expr.h:668
exprt & rhs()
Definition: std_expr.h:678
virtual const bvt & convert_bv(const exprt &expr, const std::optional< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
Definition: boolbv.cpp:39
bv_utilst bv_utils
Definition: boolbv.h:117
virtual bvt convert_floatbv_mod_rem(const binary_exprt &)
static bvt build_constant(const mp_integer &i, std::size_t width)
Definition: bv_utils.cpp:14
typet & type()
Return the type of the expression.
Definition: expr.h:84
virtual bvt rem(const bvt &src1, const bvt &src2)
void set_rounding_mode(const bvt &)
Definition: float_utils.cpp:15
ieee_float_spect spec
Definition: float_utils.h:88
std::vector< literalt > bvt
Definition: literal.h:201