mirror of https://github.com/CGAL/cgal
Add a test and more implementations
This commit is contained in:
parent
de6dd854b5
commit
42f350ef04
|
|
@ -353,21 +353,27 @@ public:
|
|||
|
||||
std::pair<double,double> to_interval() const
|
||||
{
|
||||
assert(false);
|
||||
double zero(0);
|
||||
return std::make_pair(zero,zero);
|
||||
if(exp == 0){
|
||||
return CGAL::to_interval(man);
|
||||
}
|
||||
if(exp > 0){
|
||||
Mantissa as = man << exp;
|
||||
return CGAL::to_interval(as);
|
||||
}
|
||||
Mantissa pow(1);
|
||||
pow <<= -exp;
|
||||
boost::multiprecision::cpp_rational rat(man, pow);
|
||||
return CGAL::to_interval(rat);
|
||||
}
|
||||
|
||||
|
||||
bool is_zero () const {
|
||||
return man==0 && exp == 0;
|
||||
return CGAL::is_zero(man);
|
||||
}
|
||||
|
||||
|
||||
bool is_one () const {
|
||||
assert(false);
|
||||
return true;
|
||||
// return exp==0 && size==1 && data()[0]==1;
|
||||
return *this == cpp_float(1);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -394,8 +400,7 @@ public:
|
|||
struct Is_one
|
||||
: public CGAL::cpp98::unary_function< Type, bool > {
|
||||
bool operator()( const Type& x ) const {
|
||||
assert(false);
|
||||
return false; // x.is_one();
|
||||
return x.is_one();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ include(CGAL_VersionUtils)
|
|||
include_directories(BEFORE include)
|
||||
|
||||
create_single_source_cgal_program("bench_interval.cpp")
|
||||
create_single_source_cgal_program("cpp_float.cpp")
|
||||
create_single_source_cgal_program("constant.cpp")
|
||||
create_single_source_cgal_program("CORE_BigFloat.cpp")
|
||||
create_single_source_cgal_program("CORE_BigInt.cpp")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
#include <CGAL/cpp_float.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
CGAL::cpp_float m(0);
|
||||
std::cout << m << std::endl;
|
||||
|
||||
CGAL::cpp_float m0(23.0);
|
||||
|
||||
CGAL::cpp_float m1(5.0);
|
||||
|
||||
CGAL::cpp_float m2(5.125);
|
||||
|
||||
CGAL::cpp_float m3(2.5);
|
||||
|
||||
CGAL::cpp_float m4(0.625);
|
||||
|
||||
|
||||
CGAL::cpp_float m5(0.5);
|
||||
|
||||
CGAL::is_positive(m5);
|
||||
|
||||
assert(m4 > m5);
|
||||
|
||||
assert(-m4 < -m5);
|
||||
|
||||
|
||||
assert(-m4 == -m4);
|
||||
|
||||
|
||||
assert(-m4 != -m5);
|
||||
|
||||
assert(-m5 != -m4);
|
||||
|
||||
CGAL::cpp_float m15 = m1 + m5;
|
||||
m15 = m15 - m5;
|
||||
assert(m15 == m1);
|
||||
assert(! (m15 < m1));
|
||||
assert(! (m1 < m15));
|
||||
|
||||
m15 = m15 - m15;
|
||||
std::cout << m15 << std::endl;
|
||||
assert(m15.is_zero());
|
||||
|
||||
m1 *= m5;
|
||||
|
||||
m0 += m4;
|
||||
std::cout << m0 << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue