9 int main(int argc, char ** argv)
11 typedef uint64_t Uint;
12 typedef pair<pair<Uint, Uint>, Rational<Uint> > RatPear;
14 for (int i = 0; i < (int)(1e4); ++i)
16 double test = double(rand() % (int)(1e12)) * double(rand() % (int)(1e12)) / double(rand() % (int)1e12);
17 Rational<Uint> r(test);
18 printf("%f\t%f\t%f\t%lu\t%lu\n", test, r.ToDouble(), fabs(r.ToDouble() - test), r.P, r.Q);
23 for (Uint p = 0; p < 128; ++p)
25 for (Uint q = 0; q < 128; ++q)
27 space.push_back(RatPear(pair<Uint, Uint>(p,q), Rational<Uint>(p,q)));
30 space.sort([=](const RatPear & a, const RatPear & b){return a.second < b.second;});
31 for (auto i = space.begin(); i != space.end(); ++i)
34 printf("%li\t%li\t%li\t%li\t%f\n", i->first.first, i->first.second, i->second.P, i->second.Q, i->second.ToDouble());