Changeset 8978 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 06/18/08 21:39:50 (17 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MMath.cc
r8957 r8978 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.3 8 2008-06-14 15:55:50tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.39 2008-06-18 20:39:48 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 811 811 return 3; 812 812 } 813 814 // -------------------------------------------------------------------------- 815 // 816 // Format a value and its error corresponding to the rules (note 817 // this won't work if the error is more then eight orders smaller than 818 // the value) 819 // 820 void MMath::Format(Double_t &v, Double_t &e) 821 { 822 // Valid digits 823 Int_t i = TMath::FloorNint(TMath::Log10(v))-TMath::FloorNint(TMath::Log10(e)); 824 825 // Check if error starts with 1 or 2. In this case use one 826 // more valid digit 827 TString error = Form("%.0e", e); 828 if (error[0]=='1' || error[0]=='2') 829 { 830 i++; 831 error = Form("%.1e", e); 832 } 833 834 const char *fmt = Form("%%.%de", i); 835 836 v = atof(Form(fmt, v)); 837 e = error.Atof(); 838 } -
trunk/MagicSoft/Mars/mbase/MMath.h
r8585 r8978 1 1 #ifndef MARS_MMath 2 2 #define MARS_MMath 3 4 #ifndef _MATH_H 5 #include <math.h> // Needed for darwin 6 #endif 3 7 4 8 #ifndef ROOT_TMath … … 69 73 TArrayD LeastSqFitPowerLaw(Int_t n, Double_t *x, Double_t *y); 70 74 71 inline Int_t ModF(Double_t dbl, Double_t &frac) { Double_t rc; frac = modf(dbl, &rc); return TMath::Nint(rc); }75 inline Int_t ModF(Double_t dbl, Double_t &frac) { Double_t rc; frac = ::modf(dbl, &rc); return TMath::Nint(rc); } 72 76 73 inline Double_t Sqrt3(Double_t x) { return cbrt(x); }77 inline Double_t Sqrt3(Double_t x) { return ::cbrt(x); } 74 78 75 79 inline Double_t Sgn(Double_t d) { return d<0 ? -1 : 1; } 80 81 void Format(Double_t &v, Double_t &e); 76 82 } 77 83
Note:
See TracChangeset
for help on using the changeset viewer.