2013-08-17 41 views

回答

5

您可以使用任意精度算術庫,例如GMP

甲快速C爲例:

#include <gmp.h> 

mpz_t a, b; 

const char *huge_decimal_num1 = "46819294521564960351683095841209562359068"; 
const char *huge_decimal_num2 = "69041205848645409168140568"; 

mpz_init_set_str (a, huge_decimal_num1, 10);  
mpz_init_set_str (b, huge_decimal_num2, 10);  
mpz_add (a, a, b); // a = a + b 

printf("%s + %s = %s\n", 
huge_decimal_num1, huge_decimal_num2, mpz_get_str (NULL, 10, a)); 
相關問題