fixed16 Class Reference

#include <fixed16.h>

List of all members.

Public Member Functions

 fixed16 ()
 fixed16 (const fixed16 &)
 fixed16 (INT32)
 fixed16 (short)
 fixed16 (double)
fixed16Sin ()
 Performs sine on a FIXED16.
fixed16Cos ()
 Performs Cos on a FIXED16.
fixed16 trunc () const
fixed16 round () const
fixed16 abs () const
fixed16 sgn () const
void ToString (StringBase *out) const
 Converts value of FIXED16 into a string representing it. The string will be ASCII or Unicode depending on the size of TCHAR.
fixed16operator= (const fixed16 &)
fixed16operator= (const INT32)
fixed16operator= (const short)
fixed16operator= (const double)
fixed16operator+= (const fixed16 &)
fixed16operator+= (const short)
fixed16operator-= (const fixed16 &)
fixed16operator-= (const short)
fixed16operator *= (const fixed16 &)
fixed16operator *= (const short)
fixed16operator/= (const fixed16 &)
fixed16operator/= (const short)
fixed16operator<<= (const UINT32)
fixed16operator>>= (const UINT32)
fixed16operator++ ()
fixed16 operator++ (INT32)
fixed16operator-- ()
fixed16 operator-- (INT32)
INT32 MakeInt () const
short MakeShort () const
double MakeDouble () const
INT32 MakeLong () const
xlong MakeXlong () const
INT32 GetRawLong () const
INT32 GetShifted16 () const

Static Public Member Functions

static fixed16 FromRawLong (INT32 d)
static fixed16 FromShifted16 (INT32 d)

Public Attributes

INT32 all

Friends

fixed16 Div32By32 (const INT32 a, const INT32 b)
fixed16 CCAPI operator+ (const fixed16 &, const fixed16 &)
fixed16 CCAPI operator- (const fixed16 &, const fixed16 &)
fixed16 CCAPI operator- (const fixed16 &)
fixed16 CCAPI operator * (const fixed16 &, const fixed16 &)
fixed16 CCAPI operator/ (const fixed16 &, const fixed16 &)
fixed16 CCAPI operator>> (const fixed16 &, UINT32)
fixed16 CCAPI operator<< (const fixed16 &, UINT32)
INT32 CCAPI operator== (const fixed16 &, const fixed16 &)
INT32 CCAPI operator== (const fixed16 &, const short)
INT32 CCAPI operator!= (const fixed16 &, const fixed16 &)
INT32 CCAPI operator!= (const fixed16 &, const short)
INT32 CCAPI operator> (const fixed16 &, const fixed16 &)
INT32 CCAPI operator> (const fixed16 &, const short)
INT32 CCAPI operator< (const fixed16 &, const fixed16 &)
INT32 CCAPI operator< (const fixed16 &, const short)
INT32 CCAPI operator>= (const fixed16 &, const fixed16 &)
INT32 CCAPI operator>= (const fixed16 &, const short)
INT32 CCAPI operator<= (const fixed16 &, const fixed16 &)
INT32 CCAPI operator<= (const fixed16 &, const short)


Detailed Description

Definition at line 142 of file fixed16.h.


Constructor & Destructor Documentation

fixed16::fixed16  )  [inline]
 

Definition at line 156 of file fixed16.h.

00156 {};             

fixed16::fixed16 const fixed16  )  [inline]
 

Definition at line 252 of file fixed16.h.

00253 {
00254     all = initValue.all;
00255 }

fixed16::fixed16 INT32   )  [inline]
 

Definition at line 257 of file fixed16.h.

00258 {
00259     all = SHORT_FIXED( initValue );
00260 }

fixed16::fixed16 short   )  [inline]
 

Definition at line 262 of file fixed16.h.

00263 {
00264     all = SHORT_FIXED( initValue );
00265 }

fixed16::fixed16 double   )  [inline]
 

Definition at line 267 of file fixed16.h.

00268 {
00269     *this = DoubleToFixed16(initValue);
00270 }


Member Function Documentation

fixed16 fixed16::abs  )  const [inline]
 

Definition at line 345 of file fixed16.h.

00346 {
00347     return FromRawLong( all<0 ? -all : all );
00348 }

fixed16 & fixed16::Cos  ) 
 

Performs Cos on a FIXED16.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/5/93
See also:
Fixed16Cos()
Parameters:
None. [INPUTS]
None [OUTPUTS]
Returns:
A reference to an FIXED16 with result of Cos. Input argument must be in DEGREES not radians.

Errors: None.

Definition at line 313 of file f16spec.cpp.

00314 {
00315 #ifndef WIN32
00316     if (MathCoprocInstalled)                //Is MathCoprocessor installed
00317         *this = Fixed16Cos(*this);
00318     else
00319 #endif
00320         *this = cos(TORADIANS(this->MakeDouble()));
00321 
00322 ERROR3("Alex doubts whether this routine works");
00323 
00324     return *this;
00325 }

fixed16 fixed16::FromRawLong INT32  d  )  [inline, static]
 

Definition at line 272 of file fixed16.h.

00273 {
00274     fixed16 temp;
00275     temp.all = d;
00276     return temp;
00277 }

fixed16 fixed16::FromShifted16 INT32  d  )  [inline, static]
 

Definition at line 279 of file fixed16.h.

00280 {
00281     fixed16 temp;
00282     temp.all = d;
00283     return temp;
00284 }

INT32 fixed16::GetRawLong  )  const [inline]
 

Definition at line 325 of file fixed16.h.

00326 {
00327     return this->all;
00328 }

INT32 fixed16::GetShifted16  )  const [inline]
 

Definition at line 330 of file fixed16.h.

00331 {
00332     return this->all;
00333 }

double fixed16::MakeDouble  )  const [inline]
 

Definition at line 314 of file fixed16.h.

00315 {
00316     return Fixed16ToDouble(*this);
00317 }

INT32 fixed16::MakeInt  )  const [inline]
 

Definition at line 286 of file fixed16.h.

00287 {
00288     return (INT32) (all >> F16SHIFT);
00289 }

INT32 fixed16::MakeLong  )  const [inline]
 

Definition at line 296 of file fixed16.h.

00297 {
00298     return all >> F16SHIFT;
00299 }

short fixed16::MakeShort  )  const [inline]
 

Definition at line 291 of file fixed16.h.

00292 {
00293     return (short) (all >> F16SHIFT);
00294 }

xlong fixed16::MakeXlong  )  const [inline]
 

Definition at line 301 of file fixed16.h.

00302 {
00303     return xlong( (short) (all >> F16SHIFT) );
00304 }

fixed16 & fixed16::operator *= const   short  )  [inline]
 

Definition at line 509 of file fixed16.h.

00510 {                                  
00511     fixed16 temp;
00512     
00513     temp.all = SHORT_FIXED( operand );
00514     
00515     F16ASSIGNTHIS = Fixed16Mul(*this, temp);
00516     
00517     return *this;
00518 }

fixed16 & fixed16::operator *= const fixed16  )  [inline]
 

Definition at line 502 of file fixed16.h.

00503 {
00504     F16ASSIGNTHIS = Fixed16Mul(*this, operand);
00505     
00506     return *this;
00507 }

fixed16 fixed16::operator++ INT32   )  [inline]
 

Definition at line 556 of file fixed16.h.

00557 {                
00558     fixed16 result = *this;
00559     
00560     this->all += FIXED16_ONE;
00561     
00562     return result;
00563 }

fixed16 & fixed16::operator++  )  [inline]
 

Definition at line 550 of file fixed16.h.

00551 {
00552     this->all += FIXED16_ONE;
00553     return *this;
00554 }

fixed16 & fixed16::operator+= const   short  )  [inline]
 

Definition at line 484 of file fixed16.h.

00485 { 
00486     this->all += SHORT_FIXED( operand );
00487     return *this;
00488 }

fixed16 & fixed16::operator+= const fixed16  )  [inline]
 

Definition at line 478 of file fixed16.h.

00479 { 
00480     this->all += operand.all;
00481     return *this;
00482 }

fixed16 fixed16::operator-- INT32   )  [inline]
 

Definition at line 571 of file fixed16.h.

00572 {
00573     fixed16 result = *this;
00574     
00575     this->all -= FIXED16_ONE;
00576     
00577     return result;
00578 }

fixed16 & fixed16::operator--  )  [inline]
 

Definition at line 565 of file fixed16.h.

00566 {
00567     this->all -= FIXED16_ONE;
00568     return *this;
00569 }

fixed16 & fixed16::operator-= const   short  )  [inline]
 

Definition at line 496 of file fixed16.h.

00497 {
00498     this->all -= SHORT_FIXED( operand );
00499     return *this;
00500 }

fixed16 & fixed16::operator-= const fixed16  )  [inline]
 

Definition at line 490 of file fixed16.h.

00491 {
00492     this->all -= operand.all;
00493     return *this;
00494 }

fixed16 & fixed16::operator/= const   short  )  [inline]
 

Definition at line 527 of file fixed16.h.

00528 {
00529     fixed16 temp;
00530     
00531     temp.all = SHORT_FIXED( operand );
00532     
00533     F16ASSIGNTHIS = Fixed16Div(*this, temp);
00534     
00535     return *this;
00536 }

fixed16 & fixed16::operator/= const fixed16  )  [inline]
 

Definition at line 520 of file fixed16.h.

00521 {
00522     F16ASSIGNTHIS = Fixed16Div(*this, operand);
00523     
00524     return *this;
00525 }

fixed16 & fixed16::operator<<= const   UINT32  )  [inline]
 

Definition at line 538 of file fixed16.h.

00539 {
00540     this->all <<= operand;
00541     return *this;
00542 }

fixed16 & fixed16::operator= const   double  )  [inline]
 

Definition at line 472 of file fixed16.h.

00473 { 
00474     F16ASSIGNTHIS = DoubleToFixed16(operand);
00475     return *this;
00476 }

fixed16 & fixed16::operator= const   short  )  [inline]
 

Definition at line 319 of file fixed16.h.

00320 { 
00321     this->all = SHORT_FIXED( operand );
00322     return *this;
00323 }

fixed16 & fixed16::operator= const   INT32  )  [inline]
 

Definition at line 466 of file fixed16.h.

00467 {
00468     this->all = SHORT_FIXED( operand );
00469     return *this;
00470 }

fixed16 & fixed16::operator= const fixed16  )  [inline]
 

Definition at line 307 of file fixed16.h.

00308 { 
00309     this->all = operand.all;
00310     
00311     return *this; 
00312 }

fixed16 & fixed16::operator>>= const   UINT32  )  [inline]
 

Definition at line 544 of file fixed16.h.

00545 {
00546     this->all >>= operand;
00547     return *this;
00548 } 

fixed16 fixed16::round  )  const [inline]
 

Definition at line 340 of file fixed16.h.

00341 {
00342     return FromRawLong( ( all + FIXED16_HALF ) & 0xFFFF0000L );
00343 }

fixed16 fixed16::sgn  )  const [inline]
 

Definition at line 350 of file fixed16.h.

00351 {
00352     return FromRawLong( all<0 ? -FIXED16_ONE : FIXED16_ONE );
00353 }

fixed16 & fixed16::Sin  ) 
 

Performs sine on a FIXED16.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/5/93
See also:
Fixed16Sin()
Parameters:
None. [INPUTS]
None [OUTPUTS]
Returns:
A reference to an FIXED16 with result of sin. Input argument must be in DEGREES not radians.

Errors: None.

Definition at line 283 of file f16spec.cpp.

00284 {
00285 #ifndef WIN32
00286     if (MathCoprocInstalled)                    //Is MathCoprocessor installed
00287         *this = Fixed16Sin(*this);
00288     else
00289 #endif
00290         *this = sin(TORADIANS(this->MakeDouble()));
00291 
00292 ERROR3("Alex doubts whether this routine works");
00293 
00294     return *this;
00295 }

void fixed16::ToString StringBase pOut  )  const
 

Converts value of FIXED16 into a string representing it. The string will be ASCII or Unicode depending on the size of TCHAR.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/6/93 - rewritten in C 12/8/93 by Andy - rewritten so it works: JCF 31/10/94
Parameters:
None. [INPUTS]
Returns a string representing the value of a FIXED16 in the 'out' parameter. [OUTPUTS] Optional - sign, up to five digits of integer, then option period and five fractional digits then zero terminator (max 13 character result)
Returns:
-

Errors: -

Definition at line 120 of file fixed16.cpp.

00121 {
00122     // Allocate some working storage etc.
00123     TCHAR buf[32];
00124     TCHAR* pch = buf;
00125     INT32 n = all;
00126 
00127     // If the number is negative then output a sign and make it positive.
00128     if (n < 0)
00129     {
00130         *pch++ = TEXT('-');
00131         n = -n;
00132     }
00133 
00134     // Convert and output the integer part of the number.
00135     pch += camSnprintf( pch, 256, TEXT("%u"), unsigned(n >> F16SHIFT) );
00136 
00137     // Mask off the fractional part, converting it if it exists.
00138     n &= (1uL << F16SHIFT) - 1;
00139     if (n != 0)
00140     {
00141         // Output a decimal point.
00142         *pch++ = TEXT('.');
00143 
00144         // "Normalise" into an integer by multiplying by 100000/65336.
00145         n = MulDiv32By32(n, 100000L, 65536L);
00146 
00147         // Convert and output.  We must do this ourselves as we must take
00148         // account of leading zeros.
00149         INT32 nPowerTen = 10000L;
00150         while (nPowerTen > 0)
00151         {
00152             // Is the remaining part of the number greater than our power of ten?
00153             if (n >= nPowerTen)
00154             {
00155                 // Output a non-zero digit and subtract the closest multiple of the
00156                 // power of ten.
00157                 INT32 nFactor = n / nPowerTen;
00158                 *pch++ = TEXT('0') + TCHAR(nFactor);
00159                 n -= (n * nFactor);
00160             }
00161             else
00162             {
00163                 // Output a leading zero.
00164                 *pch++ = TEXT('0');
00165             }
00166 
00167             // Go on to the next highest power of ten.
00168             nPowerTen /= 10;
00169         }
00170     }
00171 
00172     // Terminate and write into the output parameter.
00173     *pch = TEXT('\0');
00174     *pOut = buf;
00175 }

fixed16 fixed16::trunc  )  const [inline]
 

Definition at line 335 of file fixed16.h.

00336 {
00337     return FromRawLong( all & 0xFFFF0000L );
00338 }


Friends And Related Function Documentation

fixed16 Div32By32 const INT32  a,
const INT32  b
[friend]
 

Definition at line 134 of file ccmaths.h.

00135 {
00136     fixed16 v( InternalDiv32by32( a, b ) );
00137     return v;
00138 }

fixed16 CCAPI operator * const fixed16 operand1,
const fixed16 operand2
[friend]
 

Definition at line 376 of file fixed16.h.

00377 {
00378     fixed16 result;
00379     F16ASSIGN(result) = Fixed16Mul( operand1, operand2 );
00380     return result;
00381 }

INT32 CCAPI operator!= const fixed16 operand1,
const short  operand2
[friend]
 

Definition at line 421 of file fixed16.h.

00422 {
00423     return operand1.all != SHORT_FIXED( operand2 );
00424 }

INT32 CCAPI operator!= const fixed16 operand1,
const fixed16 operand2
[friend]
 

Definition at line 416 of file fixed16.h.

00417 {
00418     return operand1.all != operand2.all;
00419 }

fixed16 CCAPI operator+ const fixed16 operand1,
const fixed16 operand2
[friend]
 

Definition at line 355 of file fixed16.h.

00356 {
00357     fixed16 result;
00358     result.all = operand1.all + operand2.all;
00359     return result;
00360 }

fixed16 CCAPI operator- const fixed16 operand  )  [friend]
 

Definition at line 369 of file fixed16.h.

00370 {
00371     fixed16 temp;
00372     temp.all = -operand.all;
00373     return temp;
00374 }

fixed16 CCAPI operator- const fixed16 operand1,
const fixed16 operand2
[friend]
 

Definition at line 362 of file fixed16.h.

00363 {
00364     fixed16 result;
00365     result.all = operand1.all - operand2.all;
00366     return result;
00367 }

fixed16 CCAPI operator/ const fixed16 operand1,
const fixed16 operand2
[friend]
 

Definition at line 383 of file fixed16.h.

00384 {
00385     fixed16 result;
00386     F16ASSIGN(result) = Fixed16Div( operand1, operand2 );
00387     return result;
00388 }

INT32 CCAPI operator< const fixed16 operand1,
const short  operand2
[friend]
 

Definition at line 441 of file fixed16.h.

00442 {
00443     return operand1.all < SHORT_FIXED( operand2 );
00444 }

INT32 CCAPI operator< const fixed16 operand1,
const fixed16 operand2
[friend]
 

Definition at line 436 of file fixed16.h.

00437 {
00438     return operand1.all < operand2.all;
00439 }

fixed16 CCAPI operator<< const fixed16 operand1,
UINT32  operand2
[friend]
 

Definition at line 397 of file fixed16.h.

00398 {
00399     fixed16 result;
00400     
00401     result.all = operand1.all << operand2;
00402     
00403     return result;
00404 }

INT32 CCAPI operator<= const fixed16 operand1,
const short  operand2
[friend]
 

Definition at line 461 of file fixed16.h.

00462 {
00463     return operand1.all <= SHORT_FIXED( operand2 );
00464 }

INT32 CCAPI operator<= const fixed16 operand1,
const fixed16 operand2
[friend]
 

Definition at line 456 of file fixed16.h.

00457 {
00458     return operand1.all <= operand2.all;
00459 }

INT32 CCAPI operator== const fixed16 operand1,
const short  operand2
[friend]
 

Definition at line 411 of file fixed16.h.

00412 {
00413     return operand1.all == SHORT_FIXED( operand2 );
00414 }

INT32 CCAPI operator== const fixed16 operand1,
const fixed16 operand2
[friend]
 

Definition at line 406 of file fixed16.h.

00407 {
00408     return operand1.all == operand2.all;
00409 }

INT32 CCAPI operator> const fixed16 operand1,
const short  operand2
[friend]
 

Definition at line 431 of file fixed16.h.

00432 {
00433     return operand1.all > SHORT_FIXED(operand2);
00434 }

INT32 CCAPI operator> const fixed16 operand1,
const fixed16 operand2
[friend]
 

Definition at line 426 of file fixed16.h.

00427 {
00428     return operand1.all > operand2.all;
00429 }

INT32 CCAPI operator>= const fixed16 operand1,
const short  operand2
[friend]
 

Definition at line 451 of file fixed16.h.

00452 {
00453     return operand1.all >= SHORT_FIXED( operand2 );
00454 }

INT32 CCAPI operator>= const fixed16 operand1,
const fixed16 operand2
[friend]
 

Definition at line 446 of file fixed16.h.

00447 {
00448     return operand1.all >= operand2.all;
00449 }

fixed16 CCAPI operator>> const fixed16 operand1,
UINT32  operand2
[friend]
 

Definition at line 390 of file fixed16.h.

00391 {
00392     fixed16 result;
00393     result.all = operand1.all >> operand2;
00394     return result;
00395 }


Member Data Documentation

INT32 fixed16::all
 

Definition at line 145 of file fixed16.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