summaryrefslogtreecommitdiff
path: root/src/util/integer_cln_imp.h
diff options
context:
space:
mode:
authorTim King <taking@cs.nyu.edu>2012-12-01 02:09:02 +0000
committerTim King <taking@cs.nyu.edu>2012-12-01 02:09:02 +0000
commitb66fc3eac2717e8a887f1d4603c15cbcb7460e98 (patch)
tree83e5bfcf946d7043abdb36a809a7f17013043c4a /src/util/integer_cln_imp.h
parent5d4ee83cd9b245810c35b0aa17bb51b5a456c24b (diff)
Fix for a CLN related bug on 32 bit systems. Integer((1<<29)+1) and Integer((long int)((1<<29)+1)) gave different values. This was confirmed on vm-int1.cims.nyu.edu. See http://www.ginac.de/CLN/cln_3.html#SEC15 for more details. rational_white and integer_white have tests covering this.
Diffstat (limited to 'src/util/integer_cln_imp.h')
-rw-r--r--src/util/integer_cln_imp.h32
1 files changed, 6 insertions, 26 deletions
diff --git a/src/util/integer_cln_imp.h b/src/util/integer_cln_imp.h
index 07e85c118..211c40741 100644
--- a/src/util/integer_cln_imp.h
+++ b/src/util/integer_cln_imp.h
@@ -120,8 +120,8 @@ public:
Integer(const Integer& q) : d_value(q.d_value) {}
- Integer( signed int z) : d_value(z) {}
- Integer(unsigned int z) : d_value(z) {}
+ Integer( signed int z) : d_value((signed long int)z) {}
+ Integer(unsigned int z) : d_value((unsigned long int)z) {}
Integer( signed long int z) : d_value(z) {}
Integer(unsigned long int z) : d_value(z) {}
@@ -192,35 +192,17 @@ public:
return *this;
}
- /*
- Integer operator/(const Integer& y) const {
- return Integer( cln::floor1(d_value, y.d_value) );
- }
- Integer& operator/=(const Integer& y) {
- d_value = cln::floor1(d_value, y.d_value);
- return *this;
- }
-
- Integer operator%(const Integer& y) const {
- return Integer( cln::floor2(d_value, y.d_value).remainder );
- }
- Integer& operator%=(const Integer& y) {
- d_value = cln::floor2(d_value, y.d_value).remainder;
- return *this;
- }
- */
-
Integer bitwiseOr(const Integer& y) const {
- return Integer(cln::logior(d_value, y.d_value));
+ return Integer(cln::logior(d_value, y.d_value));
}
Integer bitwiseAnd(const Integer& y) const {
- return Integer(cln::logand(d_value, y.d_value));
+ return Integer(cln::logand(d_value, y.d_value));
}
Integer bitwiseXor(const Integer& y) const {
- return Integer(cln::logxor(d_value, y.d_value));
+ return Integer(cln::logxor(d_value, y.d_value));
}
Integer bitwiseNot() const {
@@ -401,8 +383,6 @@ public:
return d_value == -1;
}
- //friend std::ostream& operator<<(std::ostream& os, const Integer& n);
-
long getLong() const {
// ensure there isn't overflow
CheckArgument(d_value <= std::numeric_limits<long>::max(), this,
@@ -445,7 +425,7 @@ public:
*/
unsigned isPow2() const {
if (d_value <= 0) return 0;
- // power2p returns n such that d_value = 2^(n-1)
+ // power2p returns n such that d_value = 2^(n-1)
return cln::power2p(d_value);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback