numerix_doc 0.4
|
/****************************************************************************** * MODULE : rational_test.cc * DESCRIPTION: Test rational numbers * COPYRIGHT : (C) 2003 Joris van der Hoeven ******************************************************************************* * This software falls under the GNU general public license and comes WITHOUT * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details. * If you don't have this file, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ******************************************************************************/ #include <numerix/rational.hpp> using namespace mmx; int main () { rational x= rational (37) / rational (1111); rational y (3); mmout << "x\t= " << x << "\n"; mmout << "y\t= " << y << "\n"; mmout << "x+y\t= " << (x+y) << "\n"; mmout << "x-y\t= " << (x-y) << "\n"; mmout << "x*y\t= " << (x*y) << "\n"; mmout << "x/y\t= " << (x/y) << "\n"; mmout << "x+=y\t= " << (x+=y) << "\n"; mmout << "x-=y\t= " << (x-=y) << "\n"; mmout << "x*=y\t= " << (x*=y) << "\n"; mmout << "x/=y\t= " << (x/=y) << "\n"; mmout << "x<<3\t= " << (x<<3) << "\n"; mmout << "x>>3\t= " << (x>>3) << "\n"; mmout << "x<<=3\t= " << (x<<=3) << "\n"; mmout << "x>>=3\t= " << (x>>=3) << "\n"; mmout << "x=y\t= " << (x==y) << "\n"; mmout << "x!=y\t= " << (x!=y) << "\n"; mmout << "x<y\t= " << (x<y) << "\n"; mmout << "x<=y\t= " << (x<=y) << "\n"; mmout << "x>y\t= " << (x>y) << "\n"; mmout << "x>=y\t= " << (x>=y) << "\n"; return 0; }