FIXEDPOINT Class Reference

#include <epsstack.h>

List of all members.

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
FIXEDPOINToperator= (INT32 Val)

Public Attributes

INT32 Long


Detailed Description

Definition at line 111 of file epsstack.h.


Member Function Documentation

void FIXEDPOINT::FromAscii const TCHAR Str  ) 
 

Decodes the ASCII string containing a floating point number and stores it as fixed point in this object.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/02/94
Parameters:
FltPtString - string form of required number. [INPUTS]
Returns:
TRUE if ok, FALSE if not (e.g. syntax error in string)
See also:
FIXEDPOINT

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 }

FIXEDPOINT::operator INT32  )  const [inline]
 

Definition at line 116 of file epsstack.h.

00116 { return (INT32) Long; }

FIXEDPOINT& FIXEDPOINT::operator= INT32  Val  )  [inline]
 

Definition at line 117 of file epsstack.h.

00117 { this->Long = Val; return *this; }


Member Data Documentation

INT32 FIXEDPOINT::Long
 

Definition at line 114 of file epsstack.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:54:20 2007 for Camelot by  doxygen 1.4.4