如果你用1除以998001,你会得到000到999的所有三位数,除了998.
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#include <iostream> #include <mpir.h> #include <mpirxx.h> using namespace std; int main() { mpf_class f1; mpf_class f2; mpf_class f3; mp_bitcnt_t prec = 9952; mpf_set_prec(f1.get_mpf_t(), prec); mpf_set_prec(f2.get_mpf_t(), prec); mpf_set_prec(f3.get_mpf_t(), prec); f1 = 1; f2 = 21; f3 = f1 / f2; cout << "f1:" << f1 << endl; cout << "f2:" << f2 << endl; cout << "f3:" << f3 << endl; mp_bitcnt_t t = mpf_get_prec(f3.get_mpf_t()); cout << "t:" << t << endl; mp_exp_t exp = 0; char *Val= mpf_get_str(NULL, &exp, 10, 0, f3.get_mpf_t()); cout << "Val:0.000\n00" << Val << endl; cout << "exp:" << exp << endl; free(Val); } |
1 |
如果我们增加精度值,则会发现循环了,很奇妙的数字。 |
1 |
mp_bitcnt_t prec = 20000; |