numerix_doc 0.4
floating_test.cpp
/******************************************************************************
* MODULE     : floating_test.cc
* DESCRIPTION: Test floating 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/floating.hpp>
#include <numerix/rounded.hpp>
using namespace mmx;
#define Float floating<>

int
main () {
  Float x (1.0);
  mmx_bit_precision= 100;
  Float y (1.23456);
  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 << "y^y\t= " << pow(y,y) << "\n";
  mmout << "sqrt(y)\t= " << sqrt(y) << "\n";
  mmout << "exp(x)\t= " << exp(x) << "\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\n";

  typedef rounding_helper<Float >::UV Up;
  typedef rounding_helper<Float >::DV Down;
  mmout << "exp(1)\t\t= " << exp (Float (1)) << "\n";
  mmout << "sqrt(2)\t\t= " << sqrt (Float (2)) << "\n";
  mmout << "sqrt_down(2)\t= " << Down::sqrt (Float (2)) << "\n";
  mmout << "sqrt_up(2)\t= " << Up::sqrt (Float (2)) << "\n";
  mmout << "euler_down\t= " << Down::euler<Float > () << "\n";
  mmout << "euler_up\t= " << Up::euler<Float > () << "\n";
  mmout << "1_down\t\t= " << Down::as<Float > (1) << "\n";
  mmout << "1_up\t\t= " << Up::as<Float > (1) << "\n";
  mmout << "1.23_down\t= " << Down::as<Float > (1.23) << "\n";
  mmout << "1.23_up\t\t= " << Up::as<Float > (1.23) << "\n";
  mmout << "atan2(1,0)\t= " << atan2 (Float (1), Float(0)) << "\n";
  return 0;
}
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines