Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dipsywong98 committed Nov 14, 2017
1 parent 68684c9 commit aee4e26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions task1/bigDecimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,11 @@ ostream& operator<<(ostream& o, const BigDecimal& f){
return o;
}

istream& operator>>(istream& i, BigDecimal bi){
istream& operator>>(istream& i, BigDecimal& bi){
string s;
i>>s;
bi.from_string(s);
cout<<"s"<<s<<endl;
bi.from_string(s.c_str());
return i;
}

Expand Down Expand Up @@ -754,7 +755,7 @@ int BigDecimal::dot_index() const{
void BigDecimal::print() const{
Node* temp = linkList;
while(temp){
cout<<(temp->data);
if(temp->data!='+')cout<<(temp->data);
temp = temp->next;
}
}
Expand Down
5 changes: 3 additions & 2 deletions task1/bigDecimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BigDecimal {

/* #### Please add your overloading methods below. #### */
friend ostream& operator<<(ostream& o, const BigDecimal& f);
friend istream& operator>>(istream& i, BigDecimal bi);
friend istream& operator>>(istream& i, BigDecimal& bi);

bool operator==(const BigDecimal &bi)const;
bool operator==(const int &bi)const;
Expand Down Expand Up @@ -135,12 +135,13 @@ class BigDecimal {
BigDecimal& operator--();
BigDecimal operator--(int);


private:
void print() const;
string roundoff_1d(string s)const;
string to_string()const;
void drop_decimal();
bool odd()const;
private:
Node* linkList;
void clear();
bool from_string(string str);
Expand Down
4 changes: 2 additions & 2 deletions task1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
using namespace std;

char str[1024];

vector<double> val = {0,1,-2,12.5,-12.34567,98765432.1,12446,356.25,43.6725,2353.6532,2.15262,0.00003};
double v[12] = {0,1,-2,12.5,-12.34567,98765432.1,12446,356.25,43.6725,2353.6532,2.15262,0.00003};
vector<double> val(v,v + sizeof(v) / sizeof(double));

void test_sum(){
for(int i=0; i<val.size();i++){
Expand Down

0 comments on commit aee4e26

Please sign in to comment.