// Rascal, the Advanced Scientific CALculator // Copyright (C) 2001, Sebastian Ritterbusch (Rascal@Ritterbusch.de) // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more detauls. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // string output(const cxscl_interval & a) { if(rinterval_precision2>=0) { string a1,a2; a1 << SaveOpt << RndDown << Inf(a); a2 << RndUp << Sup(a) << RestoreOpt; return "LInterval("+a1+","+a2+")"; } else { int p2=rinterval_precision2; int p1=rinterval_precision1; rinterval_precision(p1,0); string b; string a1,a2; a1 << SaveOpt << RndDown << Inf(a); a2 << RndUp << Sup(a) << RestoreOpt; b=a1+","+a2; string beststring=b; l_real bestdiam=diam(stringl_interval(b)); int p3; l_real optimal=diam(a); for(p3=1;p3<=-p2;p3++) { rinterval_precision(p1,p3); a1=""; a2=""; a1 << SaveOpt << RndDown << Inf(a); a2 << RndUp << Sup(a) << RestoreOpt; b=a1+","+a2; l_real now=diam(stringl_interval(b)); if(now>b; return b; }