#include <epsstack.h>
Public Member Functions | |
void | FromAscii (const TCHAR *FltPtString) |
Decodes the ASCII string containing a floating point number and stores it as fixed point in this object. | |
operator INT32 () const | |
FIXEDPOINT & | operator= (INT32 Val) |
Public Attributes | |
INT32 | Long |
Definition at line 111 of file epsstack.h.
|
Decodes the ASCII string containing a floating point number and stores it as fixed point in this object.
Definition at line 127 of file epsstack.cpp. 00128 { 00129 // Initialise data member. 00130 Long = 0; 00131 00132 // keep a check on the sign 00133 BOOL neg = (Str[0] == '-'); 00134 00135 // Look for the decimal place 00136 INT32 i = 0; 00137 while ((Str[i] != 0) && (Str[i] != '.')) 00138 i++; 00139 00140 if (Str[i] == '.') 00141 { 00142 // Found a decimal point - extract the integer and fractional parts and use them 00143 // to construct the fixed point number. 00144 TCHAR Tmp[20]; 00145 camStrcpy(Tmp, Str); 00146 Tmp[i] = 0; 00147 Long = 0; 00148 camSscanf(Tmp, _T("%d"), &Long); 00149 Long *= 1000; 00150 00151 // Force fraction to be 3 digits at the most (as we only store with 3 digits accuracy) 00152 Tmp[i + 4] = 0; 00153 00154 // Convert fraction to integer 00155 INT32 Frac = 0; 00156 camSscanf(&(Tmp[i+1]), _T("%d"), &Frac); 00157 00158 // The fraction can be of the form .1, .10, or .100 - we must scale it correctly. 00159 INT32 FracLen = camStrlen(Tmp + i + 1); 00160 00161 if (FracLen == 1) 00162 Frac *= 100; 00163 else if (FracLen == 2) 00164 Frac *= 10; 00165 00166 // Fraction is now scaled correctly - add to integer part. 00167 if (neg) 00168 // Negative number, so subtract the fractional part 00169 Long -= Frac; 00170 else 00171 // Positive number, so add the fractional part 00172 Long += Frac; 00173 } 00174 else 00175 { 00176 // No decimal point found - just scale the integer part. 00177 Long = 0; 00178 camSscanf(Str, _T("%d"), &Long); 00179 Long *= 1000; 00180 } 00181 }
|
|
Definition at line 116 of file epsstack.h.
|
|
Definition at line 117 of file epsstack.h. 00117 { this->Long = Val; return *this; }
|
|
Definition at line 114 of file epsstack.h. |