Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing signed numbers multiplication #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MahmoudRizk
Copy link
Contributor

@MahmoudRizk MahmoudRizk commented Mar 21, 2017

There were a bug when multiplying signed numbers, so i fixed it. #26

@kasparsklavins
Copy link
Owner

Can you give an example of when it produces an incorrect result?

@MahmoudRizk
Copy link
Contributor Author

MahmoudRizk commented Mar 21, 2017

#include <iostream>
#include"bigint.h"

using namespace std;
using namespace Dodecahedron;
int main(int argc, char* argv[]){

  Bigint a("-5");
  Bigint b("-10");
  Bigint c;
  c = a * b;
  cout << c<< endl;

  return 0;
}

output : - 50
correct : 50

#include <iostream>
#include"bigint.h"

using namespace std;
using namespace Dodecahedron;
int main(int argc, char* argv[]){

  Bigint a("5");
  Bigint b("-10");
  Bigint c;
  c = a*b;
  cout << c<< endl;

  return 0;
}

output : 50
correct : -50

#include <iostream>
#include"bigint.h"

using namespace std;
using namespace Dodecahedron;
int main(int argc, char* argv[]){

  Bigint a("-5");
  Bigint c;
  c = a * -5;
  cout << c<< endl;

  return 0;
}

output: - - 25
correct: 25

#include <iostream>
#include"bigint.h"

using namespace std;
using namespace Dodecahedron;
int main(int argc, char* argv[]){

  Bigint a("234523452356235423452345");
  Bigint c;
  c = a * -2;
  cout << c<< endl;

  return 0;
}

output : -469046-904712470-846904690
correct : -469046904712470846904690

@kasparsklavins
Copy link
Owner

Okay, thanks for the pull request.

I'll go over it this weekend.

@MahmoudRizk
Copy link
Contributor Author

I recommend to check the Subtraction pull request #19 too, because i want to make sure that the division is working correctly since it depends on it.
@kasparsklavins

@kasparsklavins
Copy link
Owner

kasparsklavins commented Apr 7, 2017

Sure.
Been busy lately but I'll get to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants