summaryrefslogtreecommitdiff
path: root/src/util/rational_gmp_imp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/rational_gmp_imp.h')
-rw-r--r--src/util/rational_gmp_imp.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util/rational_gmp_imp.h b/src/util/rational_gmp_imp.h
index 37c3c8364..4635ce881 100644
--- a/src/util/rational_gmp_imp.h
+++ b/src/util/rational_gmp_imp.h
@@ -169,6 +169,14 @@ public:
return mpq_sgn(d_value.get_mpq_t());
}
+ Rational abs() const {
+ if(sgn() < 0){
+ return -(*this);
+ }else{
+ return *this;
+ }
+ }
+
Integer floor() const {
mpz_class q;
mpz_fdiv_q(q.get_mpz_t(), d_value.get_num_mpz_t(), d_value.get_den_mpz_t());
@@ -244,6 +252,10 @@ public:
return (*this);
}
+ bool isIntegral() const{
+ return getDenominator() == 1;
+ }
+
/** Returns a string representing the rational in the given base. */
std::string toString(int base = 10) const {
return d_value.get_str(base);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback