Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

set_up.C

Go to the documentation of this file.
00001 /*
00002  *  setup.C:    Basic setup for starlab programs.
00003  *
00004  *              currently, only sets output precision...
00005  *
00006  *  Name shortened to satisfy some library managers.
00007  *
00008  *.............................................................................
00009  *    version 1:  Nov 1994   Steve McMillan
00010  *    version 2:  
00011  *.............................................................................
00012  *  non-local functions: 
00013  *    set_starlab_precision
00014  *.............................................................................
00015  */
00016 
00020 
00021 #include "stdinc.h"
00022 
00023 #ifndef TOOLBOX
00024 
00025 static int precision = -2;
00026 
00027 int get_starlab_precision()
00028 {
00029     if (precision == -2) {
00030         char* s = getenv("STARLAB_PRECISION");
00031         if (s)
00032             precision = atoi(s);
00033         else
00034             //  precision = -1;
00035             //  Note by J.M. 96-Aug-5 I changed this part
00036             //  so that the default precision is 16, not 
00037             //  the system default.
00038             //  precision = 16;
00039             //  Note by J.M. 97-Jan-5 I changed 16 to 18,
00040             //  to guarantee the correctness of the last
00041             //  bit. (not tested though).
00042             precision = 18;
00043     }
00044 
00045     return precision;
00046 }
00047 
00048 void set_starlab_precision(ostream& o)
00049 {
00050     get_starlab_precision();
00051     if (precision > 0) o.precision(precision);
00052 }
00053 
00054 #else
00055 
00056 main(int argc, char** argv)
00057 {
00058     check_help();
00059     set_starlab_precision(cout);
00060     
00061     real x = sqrt(2.0);
00062     cout << "x = " << x << endl;
00063 }
00064 
00065 #endif

Generated at Sun Feb 24 09:57:15 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001