summaryrefslogtreecommitdiff
path: root/src/util/bitvector.h
diff options
context:
space:
mode:
authorlianah <lianahady@gmail.com>2012-12-12 17:26:18 -0500
committerlianah <lianahady@gmail.com>2012-12-12 17:26:18 -0500
commit751950b3ca631ed92e1af35a290642fe7b7cc0bb (patch)
tree20bfe0a785d7bebba60b2bb0572e890d95243d87 /src/util/bitvector.h
parent0e3dc441641c64e6137d85f8d7eaeb78ee562e51 (diff)
* fixed bug 481 by adding check for division by 0 in bit-vector division circuit
* added printing for total bit-vector division kinds for debugging purposes
Diffstat (limited to 'src/util/bitvector.h')
-rw-r--r--src/util/bitvector.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/util/bitvector.h b/src/util/bitvector.h
index 2c178ec2e..4cbcba50e 100644
--- a/src/util/bitvector.h
+++ b/src/util/bitvector.h
@@ -178,23 +178,25 @@ public:
Integer prod = d_value * y.d_value;
return BitVector(d_size, prod);
}
-
- BitVector unsignedDiv (const BitVector& y) const {
+ /**
+ * Total division function that returns 0 when the denominator is 0.
+ */
+ BitVector unsignedDivTotal (const BitVector& y) const {
CheckArgument(d_size == y.d_size, y);
- // TODO: decide whether we really want these semantics
if (y.d_value == 0) {
- return BitVector(d_size, Integer(0));
+ return BitVector(d_size, 0u);
}
CheckArgument(d_value >= 0, this);
CheckArgument(y.d_value > 0, y);
return BitVector(d_size, d_value.floorDivideQuotient(y.d_value));
}
-
- BitVector unsignedRem(const BitVector& y) const {
+ /**
+ * Total division function that returns 0 when the denominator is 0.
+ */
+ BitVector unsignedRemTotal(const BitVector& y) const {
CheckArgument(d_size == y.d_size, y);
- // TODO: decide whether we really want these semantics
if (y.d_value == 0) {
- return BitVector(d_size, d_value);
+ return BitVector(d_size, 0u);
}
CheckArgument(d_value >= 0, this);
CheckArgument(y.d_value > 0, y);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback