File: bigint.cpp

package info (click to toggle)
iqtree 2.0.7%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,700 kB
  • sloc: cpp: 142,571; ansic: 57,789; sh: 275; python: 242; makefile: 95
file content (40 lines) | stat: -rw-r--r-- 1,056 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <terraces/bigint.hpp>

#include <ostream>

#ifdef USE_GMP
namespace terraces {
big_integer::big_integer(index i) : m_value{i} {}
big_integer& big_integer::operator+=(const big_integer& other) {
	m_value += other.m_value;
	return *this;
}
big_integer& big_integer::operator*=(const big_integer& other) {
	m_value *= other.m_value;
	return *this;
}
bool big_integer::is_clamped() const { return false; }
const mpz_class& big_integer::value() const { return m_value; }

big_integer operator+(const big_integer& a, const big_integer& b) {
	big_integer result = a;
	result += b;
	return result;
}

big_integer operator*(const big_integer& a, const big_integer& b) {
	big_integer result = a;
	result *= b;
	return result;
}

bool operator==(const big_integer& a, const big_integer& b) { return a.value() == b.value(); }

bool operator!=(const big_integer& a, const big_integer& b) { return !(a == b); }

std::ostream& operator<<(std::ostream& stream, const big_integer& val) {
	return stream << val.value();
}

} // namespace terraces
#endif // USE_GMP