]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/misc/AliL3FFloat.h
Merged problems solved.
[u/mrichter/AliRoot.git] / HLT / misc / AliL3FFloat.h
1 #ifndef ALIL3FFLOAT_H
2 #define ALIL3FFLOAT_H
3
4 #include "AliL3RootTypes.h"
5
6 #ifndef USEFFLOAT
7 typedef Float_t AliL3FFloat;
8 #else 
9 //use Ints times Digits instead of Floats
10 #define USEINTS
11
12 #define DEFDIG 100
13 #define DEFMIN -1000000
14 #define DEFMAX  1000000
15
16 #ifdef USEINTS
17
18 //ROOT does not know about 64 bit integer
19 #ifdef no_root
20 typedef long long int Fnt_t;
21 #else 
22 typedef Int_t Fnt_t;
23 #endif
24
25 class AliL3FFloat {
26  public:
27   AliL3FFloat(const Double_t val=0) {Set(val);}
28   AliL3FFloat(const AliL3FFloat &f) {Set(f);}
29   virtual ~AliL3FFloat();
30
31   AliL3FFloat& operator = (const AliL3FFloat &f)  {Set(f); return *this;}
32   AliL3FFloat& operator = (const Double_t f)      {Set(f); return *this;}
33
34   operator const Double_t () const {return fVal;}
35   operator const Float_t  () const {return (Float_t)fVal;}
36 #ifdef no_root
37   operator const Fnt_t    () const {return (Fnt_t)fVal;}
38 #endif
39   operator const Int_t    () const {return (Int_t)fVal;}  
40
41
42   friend ostream& operator<<(ostream &os, const AliL3FFloat &f);
43
44   friend AliL3FFloat operator + (const AliL3FFloat &f1,const AliL3FFloat &f2);
45   friend AliL3FFloat operator + (const AliL3FFloat &f1,const Double_t f2);
46   friend AliL3FFloat operator + (const Double_t f1,    const AliL3FFloat &f2);
47   friend AliL3FFloat operator + (const AliL3FFloat &f1);
48   friend AliL3FFloat operator - (const AliL3FFloat &f1,const AliL3FFloat &f2);
49   friend AliL3FFloat operator - (const AliL3FFloat &f1,const Double_t f2);
50   friend AliL3FFloat operator - (const Double_t f1,    const AliL3FFloat &f2);
51   friend AliL3FFloat operator - (const AliL3FFloat &f1);
52   friend AliL3FFloat operator * (const AliL3FFloat &f1,const AliL3FFloat &f2);
53   friend AliL3FFloat operator * (const AliL3FFloat &f1,const Double_t f2);
54   friend AliL3FFloat operator * (const Double_t f1,    const AliL3FFloat &f2);
55   friend AliL3FFloat operator / (const AliL3FFloat &f1,const AliL3FFloat &f2);
56   friend AliL3FFloat operator / (const AliL3FFloat &f1,const Double_t f2);
57   friend AliL3FFloat operator / (const Double_t f1,    const AliL3FFloat &f2);
58
59   AliL3FFloat& operator += (const AliL3FFloat &f);
60   AliL3FFloat& operator += (const Double_t f);
61   AliL3FFloat& operator -= (const AliL3FFloat &f);
62   AliL3FFloat& operator -= (const Double_t f);
63   AliL3FFloat& operator *= (const AliL3FFloat &f);
64   AliL3FFloat& operator *= (const Double_t f);
65   AliL3FFloat& operator /= (const AliL3FFloat &f);
66   AliL3FFloat& operator /= (const Double_t f);
67   //==,!=,>=, ...
68   //++,--
69
70   static void PrintStat();
71   static void SetParams(Int_t dig=DEFDIG,Int_t min=DEFMIN,Int_t max=DEFMAX);
72   void Set(const Double_t f=0);
73   void Set(const AliL3FFloat &f);
74   inline Double_t GetVal()      const {return fVal;}
75   inline Double_t GetExactVal() const {return fExactVal;}
76   inline Fnt_t   GetValInt()    const {return fVali;}
77
78  private:
79
80   void   Round(Double_t f);
81   Bool_t CheckUpperBound();
82   Bool_t CheckLowerBound();
83   Bool_t CheckBounds() {return (CheckUpperBound() && CheckLowerBound());}
84
85   Fnt_t   fVali;
86   Double_t fVal;
87   Double_t fExactVal;
88
89   static Int_t fDigits;
90   static Int_t fMax; 
91   static Int_t fMin; 
92
93 #ifdef CALCSTATS
94   static Int_t fN;
95   static Int_t fNRounded;
96   static Int_t fNOpAdds;
97   static Int_t fNOpMults;
98   static Int_t fNOpDivs;
99   static Int_t fNOpSubs;
100   static Int_t fNOverFlow;
101   static Int_t fNUnderFlow;
102   static Double_t fNDiff;
103 #endif
104
105   ClassDef(AliL3FFloat,1)
106 };
107
108 #else
109
110 class AliL3FFloat {
111  public:
112   AliL3FFloat(const Double_t val=0) {Set(val);}
113   AliL3FFloat(const AliL3FFloat &f) {Set(f);}
114   virtual ~AliL3FFloat();
115
116   AliL3FFloat& operator = (const AliL3FFloat &f)  {Set(f); return *this;}
117   AliL3FFloat& operator = (const Double_t f)      {Set(f); return *this;}
118
119   operator const Double_t () const {return fVal;}
120   operator const Float_t  () const {return (Float_t)fVal;}
121   operator const Int_t    () const {return (Int_t)fVal;}
122
123   friend ostream& operator<<(ostream &os, const AliL3FFloat &f);
124
125   friend AliL3FFloat operator + (const AliL3FFloat &f1,const AliL3FFloat &f2);
126   friend AliL3FFloat operator + (const AliL3FFloat &f1,const Double_t f2);
127   friend AliL3FFloat operator + (const Double_t f1,    const AliL3FFloat &f2);
128   friend AliL3FFloat operator + (const AliL3FFloat &f1);
129   friend AliL3FFloat operator - (const AliL3FFloat &f1,const AliL3FFloat &f2);
130   friend AliL3FFloat operator - (const AliL3FFloat &f1,const Double_t f2);
131   friend AliL3FFloat operator - (const Double_t f1,    const AliL3FFloat &f2);
132   friend AliL3FFloat operator - (const AliL3FFloat &f1);
133   friend AliL3FFloat operator * (const AliL3FFloat &f1,const AliL3FFloat &f2);
134   friend AliL3FFloat operator * (const AliL3FFloat &f1,const Double_t f2);
135   friend AliL3FFloat operator * (const Double_t f1,    const AliL3FFloat &f2);
136   friend AliL3FFloat operator / (const AliL3FFloat &f1,const AliL3FFloat &f2);
137   friend AliL3FFloat operator / (const AliL3FFloat &f1,const Double_t f2);
138   friend AliL3FFloat operator / (const Double_t f1,    const AliL3FFloat &f2);
139
140   AliL3FFloat& operator += (const AliL3FFloat &f);
141   AliL3FFloat& operator += (const Double_t f);
142   AliL3FFloat& operator -= (const AliL3FFloat &f);
143   AliL3FFloat& operator -= (const Double_t f);
144   AliL3FFloat& operator *= (const AliL3FFloat &f);
145   AliL3FFloat& operator *= (const Double_t f);
146   AliL3FFloat& operator /= (const AliL3FFloat &f);
147   AliL3FFloat& operator /= (const Double_t f);
148   //==,!=,>=, ...
149   //++,--
150
151   static void PrintStat();
152   static void SetParams(Int_t dig=DEFDIG,Int_t min=DEFMIN,Int_t max=DEFMAX);
153   void Set(const Double_t f=0);
154   void Set(const AliL3FFloat &f);
155   inline Double_t GetVal()      const {return fVal;}
156   inline Double_t GetExactVal() const {return fExactVal;}
157
158  private:
159
160   Double_t Round(Double_t f);
161   Bool_t CheckUpperBound();
162   Bool_t CheckLowerBound();
163   Bool_t CheckBounds() {return (CheckUpperBound() && CheckLowerBound());}
164
165   Double_t fVal;
166   Double_t fExactVal;
167
168   static Int_t fDigits;
169   static Char_t fQuery[10];
170   static Int_t fMax;
171   static Int_t fMin;
172
173 #ifdef CALCSTATS
174   static Int_t fN;
175   static Int_t fNRounded;
176   static Int_t fNOpAdds;
177   static Int_t fNOpMults;
178   static Int_t fNOpDivs;
179   static Int_t fNOpSubs;
180   static Int_t fNOverFlow;
181   static Int_t fNUnderFlow;
182   static Double_t fNDiff;
183 #endif
184
185   ClassDef(AliL3FFloat,1)
186 };
187
188 #endif
189 #endif
190 #endif
191
192
193
194