12
12
//------------------------------------------------------------------------------
14
14
ANNOUNCE_CLASS(sPhysValue)
15
ANNOUNCE_CLASS(xRealAlgebra)
15
ANNOUNCE_CLASS(xRAlgebra)
17
17
//--------------------------------------------------------------- sPhysValue ---
20
class RANet_EXPORT sPhysValue : public sStorable /*! @todo{VB_?_RAlgebra} virtual?*/
20
class RANet_EXPORT sPhysValue : public virtual sStorable /*! @todo{PhysValues} virtual?*/
22
22
STORABLE(sPhysValue)
24
static const int MaxDigits = 8;
25
static unsigned short int MaxDigits;
26
static unsigned short int DraftNormalization; //always
27
static unsigned short int BriefNormalization; //for Text()
28
static unsigned short int SmartNormalization; //for editing
28
sPhysValue (sUnits U);
32
explicit sPhysValue (rcsUnits U);
29
33
sPhysValue (real V ,rcsUnits U);
30
34
sPhysValue (real V ,real E ,rcsUnits U);
31
35
explicit sPhysValue (real V);
32
36
sPhysValue (real V ,real E);
33
sPhysValue (sString UnitsStr);
37
explicit sPhysValue (sString UnitsStr);
38
sPhysValue (real V ,sString UnitsStr);
39
sPhysValue (real V ,real E ,sString UnitsStr);
34
40
sPhysValue (rcsPhysValue R);
35
rsPhysValue operator = (sPhysValue);
37
/*! @todo{VB_!_RAlgebra} хреново это, надо вызывать operator=(sPhysValue(V))*/
38
// rsPhysValue operator = (real);
40
/*! @todo{VB_!_RAlgebra} изничтожить? оставить только для безразмерных?*/
41
// operator real () const
42
// { return TheValueMantissa*power10(TheOrder); };
43
// bool IsUnitsless () const;
45
44
bool UnitsAreFixed () const
46
45
{ return UnitsAreFixedFlag; };
47
{ UnitsAreFixedFlag = true; };
51
{ return isinf(TheValueMantissa); };
53
{ return isnan(TheValueMantissa); };
54
bool IsPowerOfTen () const
55
{ return ThePowerOfTenFlag; };
56
sPhysValue Error () const
57
{ return sPhysValue(ArbError(),Units()); };
58
void SetError (rcsPhysValue error);
59
real ArbValue () const
48
60
{ return TheValueMantissa*power10(TheOrder); };
49
real ValueMantissa () const
61
sString Text (eTextFormat F=Plain
62
,eTextDetalization D=Casual);
63
//!< visual representation for user
64
//!< (may have side effect - normalization)
65
sString Text (eTextFormat F=Plain
66
,eTextDetalization D=Casual) const;
67
//!< visual representation for user
69
{ Normalize(SmartNormalization); };
72
rsPhysValue operator = (rcsPhysValue);
73
// bool operator == (rcsPhysValue) const;
74
bool operator < (rcsPhysValue) const;
75
sPhysValue operator + () const;
76
sPhysValue operator - () const;
77
sPhysValue operator + (rcsPhysValue) const;
78
sPhysValue operator - (rcsPhysValue) const;
79
sPhysValue operator * (rcsPhysValue) const;
80
sPhysValue operator / (rcsPhysValue) const;
81
sPhysValue operator * (real r) const
82
{ return (*this) * sPhysValue(r); };
83
sPhysValue operator / (real r) const
84
{ return (*this) / sPhysValue(r); };
85
rsPhysValue operator += (rcsPhysValue);
86
rsPhysValue operator -= (rcsPhysValue);
87
rsPhysValue operator *= (real);
88
rsPhysValue operator /= (real);
89
rsPhysValue operator << (int order_shift);
91
public://but for internal needs in RANet and RAGUI
92
real ArbError () const
93
{ return TheErrorMantissa*power10(TheOrder); };
94
real ArbValueMantissa () const
50
95
{ return TheValueMantissa; };
51
real ErrorMantissa () const
96
real ArbErrorMantissa () const
52
97
{ return TheErrorMantissa; };
54
99
{ return TheOrder; };
55
// void SetError (real);
58
100
unsigned short int Digits () const
59
101
{ return TheDigits; };
60
102
//!< число цифр после запятой при выводе,
61
103
//! актуальное с учётом погрешности
63
sString Text (eTextFormat F=Plain
64
,eTextDetalization D=Casual) const;
65
//!< visual representation for user
68
void ShiftOrder (int order_shift)
69
{ TheOrder += order_shift; };
72
/*! @todo{VB_!_RAlgebra} (rcsPhysValue) ??*/
73
// bool operator == (sPhysValue) const;
74
bool operator < (sPhysValue) const;
75
sPhysValue operator + () const;
76
sPhysValue operator - () const;
77
sPhysValue operator + (sPhysValue) const;
78
sPhysValue operator - (sPhysValue) const;
79
sPhysValue operator * (sPhysValue) const;
80
sPhysValue operator / (sPhysValue) const;
81
rsPhysValue operator += (sPhysValue);
82
rsPhysValue operator -= (sPhysValue);
83
rsPhysValue operator *= (real);
84
rsPhysValue operator /= (real);
106
void Normalize (unsigned short int level);
107
sString Txt (eTextFormat F=Plain
108
,eTextDetalization D=Casual) const;
97
117
bool ThePowerOfTenFlag;
98
118
unsigned short int TheDigits;
101
//------------------------------------------------------------- xRealAlgebra ---
103
class RANet_EXPORT xRealAlgebra : public xException
119
unsigned short int NormalizationLevel;
120
//!< 0 - possibly not normalized;
121
//!< 1 - units - untouched,
122
//!< mantissa&order - OK;
123
//!< 2 - units - within permissions;
124
//!< n - units are looking better,
125
//!< time consuming limited by c*exp(n)
131
inline sPhysValue operator * (real r ,sPhysValue v)
133
return sPhysValue(r) * v;
137
inline sPhysValue operator / (real r ,sPhysValue v)
139
return sPhysValue(r) / v;
143
inline sPhysValue Abs (rcsPhysValue V)
145
return ( V.ArbValueMantissa() < 0.0 ? -V : V );
148
//---------------------------------------------------------------- xRAlgebra ---
150
class RANet_EXPORT xRAlgebra : public xException
109
156
//------------------------------------------------------------------------------