1//<<<<<<<<<<<<<<<<<<<<<<<<<<<insertion operator overloading<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Amir Ammar
2std::ostream& operator<<(std::ostream& out, const Bigint& i){
3 for(auto b = i.m_digits.begin(); b != i.m_digits.end(); ++b){
4 out<<(*b);
5 }
6 return (out);
7}
8//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>extraction operator overloading>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Efi Fogel
9std::istream& operator>>(std::istream& in, Bigint& i) {
10 char c;
11 in.get(c);
12 if (c == '-') i.m_is_negative = true;
13 else {
14 if (! std::isdigit(c)) throw std::runtime_error("Invalid input");
15 i.m_digits.emplace_front(c);
16 }
17 while (in.get(c) && (c != 0xa)) {
18 if (! std::isdigit(c)) throw std::runtime_error("Invalid input");
19 i.m_digits.emplace_front(c);
20 }
21 i.m_digits.reverse(); // additional method to return the reversed value (the real input)
22 while(i.m_digits.front()=='0'&&i.m_digits.size()!= 1){ // while loop to earse additional zeroes
23 i.m_digits.pop_front();
24 if(i.m_digits.size()== 1)
25 break;
26 }
27 return in;
28}