Artifact 029a85274b27ccda289c953720891b01fd7e0dda
- File
_lib/numeric/bigintFake.cpp
- 2011-02-23 09:21:16 - part of checkin [4fd800b3a8] on branch trunk - Copied from private svn repository. (user: kinaba) [annotate]
- File
lib/numeric/bigintFake.cpp
- 2011-02-23 11:18:09 - part of checkin [23dfcca431] on branch trunk - renamed _lib to lib (user: kinaba) [annotate]
string add(const string& a, const string& b) { int n = max(a.size(), b.size()), carry=0; string c(n, '0'); for(int i=0; i<n; ++i) { int x = (a.size()<=i ? 0 : a[a.size()-1-i]-'0') + (b.size()<=i ? 0 : b[b.size()-1-i]-'0') + carry; c[n-1-i] = char('0'+x%10); carry = x/10; } if( carry ) c = char('0'+carry)+c; return c; }