mirror of https://github.com/CGAL/cgal
Merge pull request #1627 from mglisse/Number_types-gmpxx_IO2-glisse
I/O for Lazy_exact_nt<mpq_class>
This commit is contained in:
commit
0db03b9b7c
|
|
@ -15,8 +15,11 @@ void test_write_read()
|
|||
typedef CGAL::Polyhedron_3< Kernel > Polyhedron;
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
|
||||
typename Kernel::RT n( std::string("6369051672525773"));
|
||||
typename Kernel::RT d( std::string("4503599627370496"));
|
||||
typename Kernel::RT n, d;
|
||||
std::istringstream str_n("6369051672525773");
|
||||
str_n >> n;
|
||||
std::istringstream str_d("4503599627370496");
|
||||
str_d >> d;
|
||||
|
||||
Point p(n, 0, 0, d);
|
||||
Point q(0, n, 0, d);
|
||||
|
|
|
|||
|
|
@ -273,6 +273,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// Copied from leda_rational.h
|
||||
namespace internal {
|
||||
// See: Stream_support/include/CGAL/IO/io.h
|
||||
template <typename ET>
|
||||
void read_float_or_quotient(std::istream & is, ET& et);
|
||||
|
||||
template <>
|
||||
inline void read_float_or_quotient(std::istream & is, mpq_class& et)
|
||||
{
|
||||
internal::read_float_or_quotient<mpz_class,mpq_class>(is, et);
|
||||
}
|
||||
} // namespace internal
|
||||
|
||||
} //namespace CGAL
|
||||
|
||||
#undef CGAL_CHECK_GMP_EXPR
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <CGAL/mpq_class.h>
|
||||
#include <CGAL/Lazy_exact_nt.h>
|
||||
|
||||
#include <CGAL/Test/_test_algebraic_structure.h>
|
||||
#include <CGAL/Test/_test_real_embeddable.h>
|
||||
|
|
@ -33,6 +34,16 @@ int main() {
|
|||
mpq_class q;
|
||||
std::istringstream in("12.34");
|
||||
in >> CGAL::iformat(q);
|
||||
assert(in);
|
||||
assert(q.get_num() == 617);
|
||||
assert(q.get_den() == 50);
|
||||
}
|
||||
{
|
||||
CGAL::Lazy_exact_nt<mpq_class> x;
|
||||
std::istringstream in("12.34");
|
||||
in >> x;
|
||||
mpq_class q = x.exact();
|
||||
assert(in);
|
||||
assert(q.get_num() == 617);
|
||||
assert(q.get_den() == 50);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue