Multiplication of very long integers

后端 未结 7 1744
日久生厌
日久生厌 2021-02-09 05:57

Is there an algorithm for accurately multiplying two arbitrarily long integers together? The language I am working with is limited to 64-bit unsigned integer length (maximum int

7条回答
  •  不思量自难忘°
    2021-02-09 06:48

    Here is my code piece in C. Good old multiply method

    char *multiply(char s1[], char s2[]) {
        int l1 = strlen(s1);
        int l2 = strlen(s2);
        int i, j, k = 0, c = 0;
        char *r = (char *) malloc (l1+l2+1); // add one byte for the zero terminating string
        int temp;
    
        strrev(s1);
        strrev(s2);
        for (i = 0;i 

提交回复
热议问题