@@ -103,21 +103,19 @@ ieee_float_spect float_bvt::get_spec(const exprt &expr)
103103exprt float_bvt::abs (const exprt &op, const ieee_float_spect &spec)
104104{
105105 // we mask away the sign bit, which is the most significant bit
106- std::string mask_str (spec.width (), ' 1' );
107- mask_str[0 ]=' 0' ;
106+ const mp_integer v = power (2 , spec.width () - 1 ) - 1 ;
108107
109- constant_exprt mask (mask_str , op.type ());
108+ const constant_exprt mask (integer2bvrep (v, spec. width ()) , op.type ());
110109
111110 return bitand_exprt (op, mask);
112111}
113112
114113exprt float_bvt::negation (const exprt &op, const ieee_float_spect &spec)
115114{
116115 // we flip the sign bit with an xor
117- std::string mask_str (spec.width (), ' 0' );
118- mask_str[0 ]=' 1' ;
116+ const mp_integer v = power (2 , spec.width () - 1 );
119117
120- constant_exprt mask (mask_str , op.type ());
118+ constant_exprt mask (integer2bvrep (v, spec. width ()) , op.type ());
121119
122120 return bitxor_exprt (op, mask);
123121}
@@ -150,10 +148,9 @@ exprt float_bvt::is_zero(const exprt &src)
150148 const floatbv_typet &type=to_floatbv_type (src.type ());
151149 std::size_t width=type.get_width ();
152150
153- std::string mask_str (width, ' 1' );
154- mask_str[0 ]=' 0' ;
151+ const mp_integer v = power (2 , width - 1 ) - 1 ;
155152
156- constant_exprt mask (mask_str , src.type ());
153+ constant_exprt mask (integer2bvrep (v, width) , src.type ());
157154
158155 ieee_floatt z (type);
159156 z.make_zero ();
0 commit comments