84 return (
long) ((dblVal)*m_dblConvertInt);
99 return (lVal*m_dblConvertReal);
119 m_dblConvertReal = 0;
128 CStdFixed(
int iM,
int iN,
int iMultM = -1,
int iMultN = -1);
129 CStdFixed(
int iM,
int iN,
double dblVal,
int iMultM = -1,
int iMultN = -1);
130 CStdFixed(
int iM,
int iN,
long lVal,
int iMultM = -1,
int iMultN = -1);
141 int M() {
return m_iM;};
151 int N() {
return m_iN;};
194 m_dblVal = (float) *
this;
249 virtual void Configure(
int iM,
int iN,
int iMultM = -1,
int iMultN = -1);
265 Fixed( (
long) Convert((
double) fltVal));
281 Fixed( (
long) Convert(dblVal));
331 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
332 return this->operator+(fxB);
348 return this->operator+(fxB);
364 return this->operator+(fxB);
380 return this->operator+(fxB);
397 long lVal = m_lFixed + fxB.
m_lFixed;
403 if(lVal & m_lAddTestMask)
404 fxC.
Fixed(m_lAddNegMask | lVal);
406 fxC.
Fixed(m_lAddPosMask & lVal);
425 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
426 return this->operator+=(fxB);
442 return this->operator+=(fxB);
458 return this->operator+=(fxB);
474 return this->operator+=(fxB);
489 long lVal = m_lFixed + fxB.
m_lFixed;
495 if(lVal & m_lAddTestMask)
496 this->Fixed(m_lAddNegMask | lVal);
498 this->Fixed(m_lAddPosMask & lVal);
518 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
519 return this->operator-(fxB);
535 return this->operator-(fxB);
551 return this->operator-(fxB);
567 return this->operator-(fxB);
584 long lVal = m_lFixed - fxB.
m_lFixed;
590 if(lVal & m_lAddTestMask)
591 fxC.
Fixed(m_lAddNegMask | lVal);
593 fxC.
Fixed(m_lAddPosMask & lVal);
614 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
615 return this->operator-=(fxB);
631 return this->operator-=(fxB);
647 return this->operator-=(fxB);
663 return this->operator-=(fxB);
678 long lVal = m_lFixed - fxB.
m_lFixed;
684 if(lVal & m_lAddTestMask)
685 this->Fixed(m_lAddNegMask | lVal);
687 this->Fixed(m_lAddPosMask & lVal);
707 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
708 return this->operator*(fxB);
724 return this->operator*(fxB);
740 return this->operator*(fxB);
756 return this->operator*(fxB);
771 CStdFixed fxC(m_iMultiplyM, m_iMultiplyN);
772 int iNShift = (m_iN + fxB.
m_iN) - m_iMultiplyN;
774 __int64 lC = ((__int64) m_lFixed * (__int64) fxB.
m_lFixed);
775 fxC.
Fixed((
long) (lC >> iNShift));
795 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
796 return this->operator*(fxB);
812 return this->operator*(fxB);
828 return this->operator*(fxB);
844 return this->operator*(fxB);
859 __int64 lC = ((__int64) m_lFixed * (__int64) fxB.
m_lFixed);
860 int iNShift = (m_iN + fxB.
m_iN) - m_iMultiplyN;
862 this->Fixed( (
long) (lC >> iNShift));
882 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
883 return this->operator/(fxB);
899 return this->operator/(fxB);
915 return this->operator/(fxB);
931 return this->operator/(fxB);
946 CStdFixed fxC(m_iMultiplyM, m_iMultiplyN);
947 int iNShift = (m_iN + fxB.
m_iN) - m_iMultiplyN;
949 __int64 lC = ((__int64) m_lFixed << iNShift);
950 __int64 lD = lC/((__int64)fxB.
m_lFixed);
951 fxC.
Fixed( (
long) lD);
967 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
968 return this->operator/=(fxB);
984 return this->operator/=(fxB);
1000 return this->operator/=(fxB);
1016 return this->operator/=(fxB);
1031 int iNShift = (m_iN + fxB.
m_iN) - m_iMultiplyN;
1033 __int64 lC = ((__int64) m_lFixed << iNShift);
1034 __int64 lD = lC/((__int64)fxB.
m_lFixed);
1035 this->Fixed( (
long) lD);
1049 operator const float()
1050 {
return (
float) Convert(m_lFixed);}
1060 operator const double()
1061 {
return (
double) Convert(m_lFixed);}
1071 operator const long()
1082 operator const int()
1083 {
return (
int) m_lFixed;}
1101 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
1102 return this->operator==(fxB);
1118 return this->operator==(fxB);
1134 return this->operator==(fxB);
1150 return this->operator==(fxB);
1165 double dblA = (double) *
this;
1166 double dblB = (double) fxB;
1189 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
1190 return this->operator<(fxB);
1206 return this->operator<(fxB);
1222 return this->operator<(fxB);
1238 return this->operator<(fxB);
1253 double dblA = (double) *
this;
1254 double dblB = (double) fxB;
1276 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
1277 return this->operator<=(fxB);
1293 return this->operator<=(fxB);
1309 return this->operator<=(fxB);
1325 return this->operator<=(fxB);
1340 double dblA = (double) *
this;
1341 double dblB = (double) fxB;
1365 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
1366 return this->operator>(fxB);
1382 return this->operator>(fxB);
1398 return this->operator>(fxB);
1414 return this->operator>(fxB);
1429 double dblA = (double) *
this;
1430 double dblB = (double) fxB;
1454 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
1455 return this->operator>=(fxB);
1471 return this->operator>=(fxB);
1487 return this->operator>=(fxB);
1503 return this->operator>=(fxB);
1518 double dblA = (double) *
this;
1519 double dblB = (double) fxB;
1543 CStdFixed fxB(m_iM, m_iN, (
double) fltVal);
1544 return this->operator!=(fxB);
1560 return this->operator!=(fxB);
1576 return this->operator!=(fxB);
1592 return this->operator!=(fxB);
1607 double dblA = (double) *
this;
1608 double dblB = (double) fxB;
CStdFixed operator+=(const long lVal)
Addition assignment operator.
bool operator<(const double dblVal)
Less-than comparison operator.
unsigned long m_lMaxReal
This is the maximum real value attainable by the fixed number.
bool operator<=(CStdFixed &fxB)
Less-than-or-equal comparison operator.
CStdFixed operator*(const int iVal)
Multiplication operator.
CStdFixed operator/(const long lVal)
Division operator.
CStdFixed operator*(const CStdFixed &fxB)
Multiplication operator.
CStdFixed operator+=(const CStdFixed &fxB)
Addition assignment operator.
CStdFixed operator*=(const int iVal)
Multiplication assignment operator.
Standard fixed-point number class.
bool operator==(const long lVal)
Equality operator.
CStdFixed operator+=(const int iVal)
Addition assignment operator.
CStdFixed operator-=(const CStdFixed &fxB)
Subtraction assignment operator.
CStdFixed operator/=(const CStdFixed &fxB)
Division assignment operator.
bool operator!=(const double dblVal)
Inequality operator.
double * GetDoublePtr()
Gets the pointer to the floating-point representation of the number.
double m_dblVal
Actual value in double variable.
long m_lAddTestMask
Mask that is used to make certain that the number cannot go above the maximum number of bits...
float * GetFloatPtr()
Gets the pointer to the floating-point representation of the number.
CStdFixed operator-(const long lVal)
Negation operator.
CStdFixed operator-=(const long lVal)
Subtraction assignment operator.
bool operator<=(const float fltVal)
Less-than-or-equal comparison operator.
bool operator>=(const double dblVal)
Greater-than-or-equal comparison operator.
CStdFixed operator/(const CStdFixed &fxB)
Division operator.
CStdFixed operator/=(const long lVal)
Division assignment operator.
float GetFloat()
Gets the floating-point representation of the number.
int MultN()
Number of bits to the right of the decimal point during multiplication.
CStdFixed operator-=(const float fltVal)
Subtraction assignment operator.
bool operator>=(const float fltVal)
Greater-than-or-equal comparison operator.
double m_dblConvertReal
The value to convert a fixed-point number to a floating-point number.
int M()
Gets the number of bits to the left of the decimal point.
CStdFixed operator*(const long lVal)
Multiplication operator.
CStdFixed operator-(const CStdFixed &fxB)
Negation operator.
bool operator==(CStdFixed &fxB)
Equality operator.
double m_dblConvertInt
The value to convert a floating-point number to a fixed-point number.
bool operator>(const int iVal)
Greater-than comparison operator.
bool operator>(CStdFixed &fxB)
Greater-than comparison operator.
int N()
Gets the number of bits to the right of the decimal point.
long m_lAddNegMask
Mask that is used to make certain that the number cannot go above the maximum number of bits...
long Convert(double dblVal)
Converts floating-point number to a fixed-point number.
CStdFixed operator+(const int iVal)
Addition operator.
CStdFixed operator=(float fltVal)
Assignment operator.
bool operator>(const double dblVal)
Greater-than comparison operator.
bool operator<=(const int iVal)
Less-than-or-equal comparison operator.
long m_lAddPosMask
Mask that is used to make certain that the number cannot go above the maximum number of bits...
float m_fltVal
Actual value in float variable.
CStdFixed()
Default constructor.
bool operator<=(const long lVal)
Less-than-or-equal comparison operator.
CStdFixed operator=(long lVal)
Assignment operator.
CStdFixed operator/=(const float fltVal)
Division assignment operator.
int MultM()
Number of bits to the left of the decimal point during multiplication.
CStdFixed operator+=(const double dblVal)
Addition assignment operator.
bool operator<(const int iVal)
Less-than comparison operator.
CStdFixed operator+(const long lVal)
Addition operator.
CStdFixed operator/(const double dblVal)
Division operator.
bool operator<(CStdFixed &fxB)
Less-than comparison operator.
void Fixed(long lVal)
Sets the fixed-point representation of the number.
long m_lFixed
The fixed-point representation of the number.
bool operator>=(CStdFixed &fxB)
Greater-than-or-equal comparison operator.
CStdFixed operator=(double dblVal)
Assignment operator.
Namespace for the standard utility objects.
bool operator>=(const long lVal)
Greater-than-or-equal comparison operator.
long FixedVal()
Gets the fixed-point representation of the number.
double GetDouble()
Gets the double representation of the number.
std::ostream & operator<<(std::ostream &output)
stream output operator.
CStdFixed operator+(const CStdFixed &fxB)
Addition operator.
CStdFixed operator-=(const double dblVal)
Subtraction assignment operator.
bool operator>(const float fltVal)
Greater-than comparison operator.
unsigned long m_lMaxInt
This is the maximum integer value attainable by the fixed number.
CStdFixed operator+(const float fltVal)
Addition operator.
CStdFixed operator*(const double dblVal)
Multiplication operator.
bool operator>=(const int iVal)
Greater-than-or-equal comparison operator.
double Convert(long lVal)
Converts a fixed-point number to a floating-point number.
bool operator==(const int iVal)
Equality operator.
CStdFixed operator/(const float fltVal)
Division operator.
bool operator!=(CStdFixed &fxB)
Inequality operator.
bool operator<=(const double dblVal)
Less-than-or-equal comparison operator.
CStdFixed operator*=(const CStdFixed &fxB)
Multiplication assignment operator.
CStdFixed operator/=(const double dblVal)
Division assignment operator.
bool operator!=(const long lVal)
Inequality operator.
bool operator<(const float fltVal)
Less-than comparison operator.
CStdFixed operator*(const float fltVal)
Multiplication operator.
bool operator==(const double dblVal)
Equality operator.
CStdFixed operator+=(const float fltVal)
Addition assignment operator.
CStdFixed operator*=(const double dblVal)
Multiplication assignment operator.
bool operator<(const long lVal)
Less-than comparison operator.
bool operator!=(const float fltVal)
= operators
bool operator!=(const int iVal)
Inequality operator.
bool operator==(const float fltVal)
Equality operator.
CStdFixed operator/(const int iVal)
Division operator.
CStdFixed operator+(const double dblVal)
Addition operator.
CStdFixed operator-(const int iVal)
Negation operator.
CStdFixed operator*=(const float fltVal)
Multiplication assignment operator.
CStdFixed operator=(int iVal)
Assignment operator.
CStdFixed operator-=(const int iVal)
Subtraction assignment operator.
CStdFixed operator-(const float fltVal)
Negation operator.
CStdFixed operator/=(const int iVal)
Division assignment operator.
CStdFixed operator-(const double dblVal)
Negation operator.
CStdFixed operator*=(const long lVal)
Multiplication assignment operator.
bool operator>(const long lVal)
Greater-than comparison operator.
long * GetLongPtr()
Gets the pointer to the fixed-point representation of the number.