RE: [ROOT] How can I choose the accuracy of numbers ?

From: Luis March Ruiz (march@ific.uv.es)
Date: Wed May 26 2004 - 20:33:07 MEST


  This mailing list is incredible !!!

  Thanks very much to both (your replies were very fast),

  I finally got it making 

  fprintf(foutput," %s    %8.4lf    %8.4lf      %8.4lf       %8.4lf      
%8.4lf \n",histo,p0[i],e0[i],Chi2_offset,Chi_2_red,Kolmog_comp[i]);

  as Valeri said me, but between "%" and "lf" (8 is the total width and 4 
is the decimal digits that I chose).

  Stilianos, #include <iomanip> will help me also, because I will use it 
soon.
 
  Best regards,

                                                   Luis


> Check "Using printf() for Output in C Programs (PDF)"
> 
> http://www.wvutech.edu/mclark/CS%20Eng%20I/Using%20printf2.pdf
> 
> 
> ----
> Best regards
>                    Valeri
> 
> 
> > -----Original Message-----
> > From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch] On
> > Behalf Of Valeri Fine
> > Sent: Wednesday, May 26, 2004 1:32 PM
> > To: 'Luis March Ruiz'; roottalk@pcroot.cern.ch
> > Subject: RE: [ROOT] How can I choose the accuracy of numbers ?
> > 
> > See (for example or any other C/C++ book Web site )
> > 
> > http://www.lysator.liu.se/c/bwk-tutor.html#simple-io
> > "  . . .
> > printf will format floating point numbers: ``%w.df'' in the format
> > string will print the corresponding variable in a field w digits wide,
> > with d decimal places.  An e instead of an f will produce exponential
> > notation.
> >  . . . "
> > 
> > ----
> > Best regards
> >                    Valeri
> > 
> > 
> > > -----Original Message-----
> > > From: owner-roottalk@pcroot.cern.ch
> > [mailto:owner-roottalk@pcroot.cern.ch] On
> > > Behalf Of Luis March Ruiz
> > > Sent: Wednesday, May 26, 2004 1:07 PM
> > > To: roottalk@pcroot.cern.ch
> > > Subject: [ROOT] How can I choose the accuracy of numbers ?
> > >
> > >
> > >   Dear ROOT users,
> > >
> > >   I copy some results to a txt file (it goes OK),
> > >
> > >   fprintf(foutput," %s    %g     %g      %g       %g      %g \n",
> > > histo,p0[i],e0[i],Chi2_offset,Chi_2/(n_bin*1.0-1.0),Kolmog_comp[i]);
> > >
> > >   All these numbers are declared as Double_t.
> > >
> > >   my problem is:
> > >
> > >   How can I choose the accuracy of numbers ?
> > >
> > >   I would like to put them in columns with the same width (i.e. with
> > the
> > > same number of digits for all numbers).
> > >
> > >   I have been looking for SetPrecision or something like that, but I
> > > didn't find nothing (only TGNumberFormat, but there isn't any
> > example).
> > >
> > >   I apologize for any inconvenience.
> > >
> > >   Thanks.
> > >
> > >   Best regards,
> > >
> > >                                                     Luis
> 
> 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET