Which library should I use on OSX for arbitrary precision arithmetic?

江枫思渺然 提交于 2019-11-28 13:04:40

问题


I tried already GMP, MPFR. But I can't accomplish a simple division like below. BTW I have LLVM compiler in Xcode. I try to compile, run it to IOS Simulator.

mpf_t a;

mpf_init2 (a, 256);

mpf_set_d(a, 0.7);

mpf_t b; mpf_init2 (b, 256);

mpf_set_d(b, 1.0);

mpf_t l; mpf_init2 (l, 256);

gmp_printf ("%.*Ff \n", 5, a); --- 0.70000

gmp_printf ("%.*Ff \n", 5, b); --- 1.00000

mpf_div(l, a, b);

gmp_printf ("%.*Ff", 5, l); --- 0.52502


回答1:


Have you tried MPIR? OpenSSL also provides a big number library...



来源:https://stackoverflow.com/questions/11037165/which-library-should-i-use-on-osx-for-arbitrary-precision-arithmetic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!