开发者

GMP limitation big integer

开发者 https://www.devze.com 2023-03-10 10:38 出处:网络
i have a problem with GMP library for big integer. I set the big integer using the function mpz_t num; mpz_init(num);

i have a problem with GMP library for big integer. I set the big integer using the function

mpz_t num;

mpz_init(num);

mpz_set_str(num,"12345678901234567890开发者_如何学Go1234567890123456789012345678901234567890123456789012341234567890123456789012345678901234567890123456789012345678901234567890123412345678901234567890123456789012345678901234567890123456",10);

When i print this number gmp_printf("%Zd",num) the result is wrong. Are there any limitations? Is the number too big? i don't think ...


Try this:

mpf_set_default_prec(5*1024);

before your mpz_init.

Good Luck!


Maybe the problem is that you didn't initialize num. The GMP functions for integer arithmetic assume that all integer objects are initialized.

mpz_init(num);
0

精彩评论

暂无评论...
验证码 换一张
取 消