diff options
Diffstat (limited to 'src/util/integer.h')
-rw-r--r-- | src/util/integer.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/util/integer.h b/src/util/integer.h index 2aa8b711a..c019144a9 100644 --- a/src/util/integer.h +++ b/src/util/integer.h @@ -52,8 +52,8 @@ public: /** * Constructs a Integer from a C string. - * Throws std::invalid_argument if the stribng is not a valid rational. - * For more information about what is a vaid rational string, + * Throws std::invalid_argument if the string is not a valid rational. + * For more information about what is a valid rational string, * see GMP's documentation for mpq_set_str(). */ Integer(const char * s, int base = 10): d_value(s,base) {} @@ -120,6 +120,16 @@ public: return Integer( d_value / y.d_value ); } + /** Raise this Integer to the power <code>exp</code>. + * + * @param exp the exponent + */ + Integer pow(unsigned long int exp) const { + mpz_class result; + mpz_pow_ui(result.get_mpz_t(),d_value.get_mpz_t(),exp); + return Integer( result ); + } + std::string toString(int base = 10) const{ return d_value.get_str(base); } |