Long multiplication: Difference between revisions
Content added Content deleted
(Added Scala) |
|||
Line 408: | Line 408: | ||
#define X(V,L,I) ( ((I)<(L)) ? (V[(L)-(I)-1]-'0') : 0) |
#define X(V,L,I) ( ((I)<(L)) ? (V[(L)-(I)-1]-'0') : 0) |
||
#define MIN(A,B) ( ((A)<(B)) ? (A) : (B) ) |
#define MIN(A,B) ( ((A)<(B)) ? (A) : (B) ) |
||
char * |
char *longmult(const char *a, const char *b) |
||
{ |
{ |
||
int n, m, T; |
int n, m, T; |
||
char *r = NULL; |
char *r = NULL; |
||
int i, j, k |
int i, j, k; |
||
int *C, *R; |
int *C, *R; |
||
Line 459: | Line 459: | ||
/* printf("%s * %s = 340282366920938463463374607431768211456\n", n1, n1); */ |
/* printf("%s * %s = 340282366920938463463374607431768211456\n", n1, n1); */ |
||
res = |
res = longmult(n1,n1); |
||
for(lz=0; (lz < strlen(res)) && (res[lz]=='0') ;lz++) ; |
for(lz=0; (lz < strlen(res)) && (res[lz]=='0') ;lz++) ; |
||
printf("%s * %s = %s\n", n1, n1, res+lz); |
printf("%s * %s = %s\n", n1, n1, res+lz); |