Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions regression/smt2_solver/fp/bit-to-fp1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
bit-to-fp1.smt2

^EXIT=0$
^SIGNAL=0$
^unsat$
--
14 changes: 14 additions & 0 deletions regression/smt2_solver/fp/bit-to-fp1.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
;
; convert (_ bv1 1) to double precision FP,
; and check whether that is equal to 1.0.
;
(define-fun B0 () Bool (=
((_ to_fp_unsigned 11 53) roundNearestTiesToAway (_ bv1 1))
(fp #b0 #b01111111111 #b0000000000000000000000000000000000000000000000000000)))

(assert (not B0))

; expected to be UNSAT, i.e., they are equal
(check-sat)

(exit)
11 changes: 9 additions & 2 deletions src/solvers/floatbv/float_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ void float_utilst::normalization_shift(bvt &fraction, bvt &exponent)
literalt shift=prop.land(equal);

// build shifted value
bvt shifted_fraction=bv_utils.shift(fraction, bv_utilst::LEFT, i);
bvt shifted_fraction=bv_utils.shift(fraction, bv_utilst::shiftt::SHIFT_LEFT, i);
bv_utils.cond_implies_equal(shift, shifted_fraction, new_fraction);

// build new exponent
Expand Down Expand Up @@ -950,11 +950,18 @@ void float_utilst::normalization_shift(bvt &fraction, bvt &exponent)

bvt exponent_delta=bv_utils.zeros(exponent.size());

// Fraction smaller than the max distance? Pad up with zeros.
std::size_t max_distance = 1 << (depth - 1);

if(fraction.size() < max_distance)
fraction = bv_utils.zero_extension(fraction, max_distance);

for(int d=depth-1; d>=0; d--)
{
std::size_t distance=(1<<d);

INVARIANT(
fraction.size() > distance, "fraction must be larger than distance");
fraction.size() >= distance, "fraction must be larger or equal distance");

// check if first 'distance'-many bits are zeros
const bvt prefix=bv_utils.extract_msb(fraction, distance);
Expand Down
Loading