Advertisement
istinishat

BigInt Multiplication

Oct 7th, 2017
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string multiply(string a,int b) {
  2.         // a contains the biginteger in reversed form
  3.     int carry=0;
  4.     for(int i=0;i<a.size();i++) {
  5.         carry+=(a[i]-48)*b;
  6.         a[i]=(carry%10+48);
  7.         carry/=10;
  8.     }
  9.     while(carry) {
  10.         a+=(carry%10+48);
  11.         carry/=10;
  12.     }
  13.     // a contains the biginteger in reversed form
  14.     return a;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement