3 // Author: Constantin Loizides <mailto:loizides@fi.uib.no>
4 //*-- Copyright & copy CL
11 #include "AliL3Logging.h"
12 #include "AliL3Logger.h"
13 #include "AliL3FFloat.h"
15 /** \class AliL3FFloat
17 //----------------------------------------------------
20 // Fixed Floating Point class for debugging purposes.
22 // The class behaves like a normal Double_t class but
23 // calculates everything in respect to fDigits (eg.
24 // fDigits=100 -> 2 digits behind the comma). Further-
25 // more it keeps the exact value in floating precision
26 // and gathers some statistical information about
34 Int_t AliL3FFloat::fDigits = DEFDIG;
35 Int_t AliL3FFloat::fMax = DEFMAX;
36 Int_t AliL3FFloat::fMin = DEFMIN;
38 Int_t AliL3FFloat::fN = 0;
39 Int_t AliL3FFloat::fNRounded = 0;
40 Int_t AliL3FFloat::fNOpAdds = 0;
41 Int_t AliL3FFloat::fNOpMults = 0;
42 Int_t AliL3FFloat::fNOpDivs = 0;
43 Int_t AliL3FFloat::fNOpSubs = 0;
44 Int_t AliL3FFloat::fNOverFlow = 0;
45 Int_t AliL3FFloat::fNUnderFlow = 0;
47 ostream& operator<<(ostream &os, const AliL3FFloat &f)
49 // os << (Double_t)f << endl;
50 os << (Double_t)f << "(" << f.fExactVal << ")" << endl;
54 AliL3FFloat operator + (const AliL3FFloat &f1,const AliL3FFloat &f2)
61 AliL3FFloat operator + (const AliL3FFloat &f1,const Double_t f2)
68 AliL3FFloat operator + (const Double_t f1,const AliL3FFloat &f2)
75 AliL3FFloat operator + (const AliL3FFloat &f)
82 AliL3FFloat operator - (const AliL3FFloat &f1,const AliL3FFloat &f2)
89 AliL3FFloat operator - (const AliL3FFloat &f1,const Double_t f2)
96 AliL3FFloat operator - (const Double_t f1,const AliL3FFloat &f2)
103 AliL3FFloat operator - (const AliL3FFloat &f)
105 AliL3FFloat r((-(Double_t)f));
109 AliL3FFloat operator * (const AliL3FFloat &f1,const AliL3FFloat &f2)
116 AliL3FFloat operator / (const AliL3FFloat &f1,const AliL3FFloat &f2)
123 AliL3FFloat& AliL3FFloat::operator += (const AliL3FFloat &f)
125 Double_t ev=fExactVal+f.GetExactVal();
126 Set(fVal+(Double_t)f);
132 AliL3FFloat& AliL3FFloat::operator += (const Double_t f)
134 Double_t ev=fExactVal+f;
141 AliL3FFloat& AliL3FFloat::operator -= (const AliL3FFloat &f)
143 Double_t ev=fExactVal-f.GetExactVal();
144 Set(fVal-(Double_t)f);
150 AliL3FFloat& AliL3FFloat::operator -= (const Double_t f)
152 Double_t ev=fExactVal-f;
159 AliL3FFloat& AliL3FFloat::operator *= (const AliL3FFloat &f)
161 Double_t ev=fExactVal*f.GetExactVal();
162 Set(fVal*(Double_t)f);
168 AliL3FFloat& AliL3FFloat::operator *= (const Double_t f)
170 Double_t ev=fExactVal*f;
177 AliL3FFloat& AliL3FFloat::operator /= (const AliL3FFloat &f)
179 Double_t ev=fExactVal/f.GetExactVal();
180 Set(fVal/(Double_t)f);
186 AliL3FFloat& AliL3FFloat::operator /= (const Double_t f)
188 Double_t ev=fExactVal/f;
195 void AliL3FFloat::Set(Double_t val)
203 void AliL3FFloat::Set(AliL3FFloat &f)
206 fExactVal=f.GetExactVal();
211 Double_t AliL3FFloat::Round(Double_t val)
213 Int_t dummy=Int_t(fDigits*val);
214 Double_t ret=(Double_t)(dummy)/fDigits;
215 if(ret!=val) fNRounded++;
219 Bool_t AliL3FFloat::CheckUpperBound()
230 Bool_t AliL3FFloat::CheckLowerBound()
241 void AliL3FFloat::SetParams(Int_t dig,Int_t min,Int_t max)
248 void AliL3FFloat::PrintStat(){
249 cout << "fN: " << fN << endl;
250 cout << "fNRounded: " << fNRounded << endl;
251 cout << "fNOpAdds: " << fNOpAdds << endl;
252 cout << "fNOpSubs: " << fNOpSubs << endl;
253 cout << "fNOpMults: " << fNOpMults << endl;
254 cout << "fNOpDivs: " << fNOpDivs << endl;
255 cout << "fNOpOverFlow: " << fNOverFlow << endl;
256 cout << "fNOpUnderFlow: " << fNUnderFlow << endl;