Prev Next a_double_compare_xam.cpp Headings

@(@\newcommand{\B}[1]{ {\bf #1} } \newcommand{\R}[1]{ {\rm #1} }@)@
C++: a_double Comparison Operators: Example and Test
# include <cstdio>
# include <cppad/py/cppad_py.hpp>

bool a_double_compare_xam(void) {
     using cppad_py::a_double;
     bool ok = true;
     a_double a2(2.0);
     a_double a3(3.0);
     //------------------------------------------------------------------------
     ok = ok && a2   <  a3;
     ok = ok && a2   <= a3;
     ok = ok && a3 >  a2;
     ok = ok && a3 >= a2;
     ok = ok && a3 != a2;
     ok = ok && a3 == a3;
     //
     ok = ok && ! (a2 >  a3) ;
     ok = ok && ! (a2 >= a3) ;
     ok = ok && ! (a2 == a3) ;
     //------------------------------------------------------------------------
     ok = ok && a2   <  3.0;
     ok = ok && a2   <= 3.0;
     ok = ok && a3 >  2.0;
     ok = ok && a3 >= 2.0;
     ok = ok && a3 != 2.0;
     ok = ok && a3 == 3.0;
     //
     ok = ok && ! (a2 >  3.0) ;
     ok = ok && ! (a2 >= 3.0) ;
     ok = ok && ! (a2 == 3.0) ;
     //
     return( ok );
}

Input File: lib/example/cplusplus/a_double_compare_xam.cpp