Example #1
0
Mod& Mod::operator*=(const Mod& m){ //repeated doubling is used for efficiency and prevention of overflow
	long b = m.val();
	Mod temp = 0; 
	while (b > 0){
		if (b % 2 == 1){
			temp += *this;
		}
		*this += *this;
		b = b / 2;
	}
	x = temp.val();
	return *this;
}
Example #2
0
bool operator!=(const Mod& a, const Mod& b) {
	return a.val() != b.val();
}
Example #3
0
bool operator==(const Mod& a, const Mod& b) {
	return a.val() == b.val();
}
Example #4
0
Mod::Mod(const Mod& m) {
	this->x = m.val();
}
Example #5
0
bool operator!=(long t, const Mod& m){
	return (!(t == m.val()));
}
Example #6
0
bool operator!=(const Mod& a, const Mod& b){
	return (!(a.val() == b.val()));
}