<< "base 2, 10, or 16";
Integer val(s, base);
- CVC4_API_CHECK(val.modByPow2(size) == val)
- << "Overflow in bitvector construction (specified bitvector size " << size
- << " too small to hold value " << s << ")";
+
+ if (val.strictlyNegative())
+ {
+ CVC4_API_CHECK(val >= -Integer("2", 10).pow(size - 1))
+ << "Overflow in bitvector construction (specified bitvector size "
+ << size << " too small to hold value " << s << ")";
+ }
+ else
+ {
+ CVC4_API_CHECK(val.modByPow2(size) == val)
+ << "Overflow in bitvector construction (specified bitvector size "
+ << size << " too small to hold value " << s << ")";
+ }
return mkValHelper<CVC4::BitVector>(CVC4::BitVector(size, val));
}
TS_ASSERT_THROWS_NOTHING(d_solver->mkBitVector("1234", 10));
TS_ASSERT_THROWS_NOTHING(d_solver->mkBitVector("1010", 16));
TS_ASSERT_THROWS_NOTHING(d_solver->mkBitVector("a09f", 16));
+ TS_ASSERT_THROWS_NOTHING(d_solver->mkBitVector(8, "-127", 10));
TS_ASSERT_THROWS(d_solver->mkBitVector(size0, val1), CVC4ApiException&);
TS_ASSERT_THROWS(d_solver->mkBitVector(size0, val2), CVC4ApiException&);
TS_ASSERT_THROWS(d_solver->mkBitVector("", 2), CVC4ApiException&);
TS_ASSERT_THROWS(d_solver->mkBitVector("10", 3), CVC4ApiException&);
TS_ASSERT_THROWS(d_solver->mkBitVector("20", 2), CVC4ApiException&);
TS_ASSERT_THROWS(d_solver->mkBitVector(8, "101010101", 2), CVC4ApiException&);
+ TS_ASSERT_THROWS(d_solver->mkBitVector(8, "-256", 10), CVC4ApiException&);
TS_ASSERT_EQUALS(d_solver->mkBitVector("1010", 2),
d_solver->mkBitVector("10", 10));
TS_ASSERT_EQUALS(d_solver->mkBitVector("1010", 2),
"0bin01010101");
TS_ASSERT_EQUALS(d_solver->mkBitVector(8, "F", 16).toString(),
"0bin00001111");
+ TS_ASSERT_EQUALS(d_solver->mkBitVector(8, "-1", 10),
+ d_solver->mkBitVector(8, "FF", 16));
}
void SolverBlack::testMkVar()