0022627: Change OCCT memory management defaults
[occt.git] / src / Standard / Standard_ShortReal.hxx
CommitLineData
7fd59977 1#ifndef _Standard_ShortReal_HeaderFile
2#define _Standard_ShortReal_HeaderFile
3
4#include <float.h>
5#include <math.h>
6#ifndef _Standard_values_HeaderFile
7# include <Standard_values.h>
8#endif
9
10
11#ifndef _Standard_TypeDef_HeaderFile
12#include <Standard_TypeDef.hxx>
13#endif
14
15class Handle_Standard_Type;
16
34781c33 17__Standard_API const Handle_Standard_Type& Standard_ShortReal_Type_();
7fd59977 18//class Standard_OStream;
19//void ShallowDump (const Standard_ShortReal, Standard_OStream& );
20
21 // *********************************** //
22 // Class methods //
23 // //
24 // Machine-dependant values //
25 // Should be taken from include file //
26 // *********************************** //
27
28//-------------------------------------------------------------------
29// ShortRealSmall : Returns the smallest positive ShortReal
30//-------------------------------------------------------------------
31inline Standard_ShortReal ShortRealSmall()
32{ return FLT_MIN; }
33
34//-------------------------------------------------------------------
35// Abs : Returns the absolute value of a ShortReal
36//-------------------------------------------------------------------
37inline Standard_ShortReal Abs(const Standard_ShortReal Value)
38#if defined (__alpha) || defined(DECOSF1)
39{ return fabsf(Value); }
40#else
41{ return float( fabs (Value) ) ; }
42#endif
43
44//-------------------------------------------------------------------
45// ShortRealDigit : Returns the number of digits of precision in a ShortReal
46//-------------------------------------------------------------------
47inline Standard_Integer ShortRealDigits()
48{ return FLT_DIG; }
49
50//-------------------------------------------------------------------
51// ShortRealEpsilon : Returns the minimum positive ShortReal such that
52// 1.0 + x is not equal to 1.0
53//-------------------------------------------------------------------
54inline Standard_ShortReal ShortRealEpsilon()
55{ return FLT_EPSILON; }
56
57//-------------------------------------------------------------------
58// ShortRealFirst : Returns the minimum negative value of a ShortReal
59//-------------------------------------------------------------------
60inline Standard_ShortReal ShortRealFirst()
61{ Standard_ShortReal MaxFloatTmp = -FLT_MAX;
62 return MaxFloatTmp; }
63
64//-------------------------------------------------------------------
65// ShortRealFirst10Exp : Returns the minimum value of exponent(base 10) of
66// a ShortReal.
67//-------------------------------------------------------------------
68inline Standard_Integer ShortRealFirst10Exp()
69{ return FLT_MIN_10_EXP; }
70
71//-------------------------------------------------------------------
72// ShortRealLast : Returns the maximum value of a ShortReal
73//-------------------------------------------------------------------
74inline Standard_ShortReal ShortRealLast()
75{ return FLT_MAX; }
76
77//-------------------------------------------------------------------
78// ShortRealLast10Exp : Returns the maximum value of exponent(base 10) of
79// a ShortReal.
80//-------------------------------------------------------------------
81inline Standard_Integer ShortRealLast10Exp()
82{ return FLT_MAX_10_EXP; }
83
84//-------------------------------------------------------------------
85// ShortRealMantissa : Returns the size in bits of the matissa part of a
86// ShortReal.
87//-------------------------------------------------------------------
88inline Standard_Integer ShortRealMantissa()
89{ return FLT_MANT_DIG; }
90
91//-------------------------------------------------------------------
92// ShortRealRadix : Returns the radix of exponent representation
93//-------------------------------------------------------------------
94inline Standard_Integer ShortRealRadix()
95{ return FLT_RADIX; }
96
97//-------------------------------------------------------------------
98// ShortRealSize : Returns the size in bits of an integer
99//-------------------------------------------------------------------
100inline Standard_Integer ShortRealSize()
101{ return BITS(Standard_ShortReal); }
102
103//-------------------------------------------------------------------
104// Max : Returns the maximum value of two ShortReals
105//-------------------------------------------------------------------
106inline Standard_ShortReal Max (const Standard_ShortReal Val1,
107 const Standard_ShortReal Val2)
108{
109 if (Val1 >= Val2) {
110 return Val1;
111 } else {
112 return Val2;
113 }
114}
115
116//-------------------------------------------------------------------
117// Min : Returns the minimum value of two ShortReals
118//-------------------------------------------------------------------
119inline Standard_ShortReal Min (const Standard_ShortReal Val1,
120 const Standard_ShortReal Val2)
121{
122 if (Val1 <= Val2) {
123 return Val1;
124 } else {
125 return Val2;
126 }
127}
128
129// ===============================================
130// Methods from Standard_Entity class which are redefined:
131// - Hascode
132// - IsEqual
133// - IsSimilar
134// - Shallowcopy
135// - ShallowDump
136// ===============================================
137
138// ==================================
139// Methods implemeted in Standard_ShortReal.cxx
140// ==================================
141//.... Herited from Standard_Storable
142__Standard_API Standard_Integer HashCode (const Standard_ShortReal, const Standard_Integer);
143__Standard_API Standard_ShortReal ShallowCopy (const Standard_ShortReal );
144
145//-------------------------------------------------------------------
146// IsEqual : Returns Standard_True if two ShortReals are equal
147//-------------------------------------------------------------------
148inline Standard_Boolean IsEqual (const Standard_ShortReal Value1,
149 const Standard_ShortReal Value2)
150{ return Abs((Value1 - Value2)) < ShortRealSmall(); }
151
152//-------------------------------------------------------------------
153// IsSimilar : Returns Standard_True if two ShortReals are equal
154//-------------------------------------------------------------------
155inline Standard_Boolean IsSimilar(const Standard_ShortReal One,
156 const Standard_ShortReal Two)
157{ return IsEqual (One,Two); }
158
159#endif
160
161