00001 // $Id: fixed24.cpp 1282 2006-06-09 09:46:49Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 00099 00100 /* 00101 */ 00102 00103 // Stardate 070494.10:25. Captain's Log - supplementary 00104 // ==================================================== 00105 // 00106 // Pirated fixed16 code to base fixed24 upon 00107 // This was from revision 1.24 of fixed16.cpp 00108 // Jason 00109 00110 00111 00112 #include "camtypes.h" 00113 //#include "fixed24.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00114 00115 // this is a temporary kludge for the 32-bit MS compiler 00116 #define F24ASSIGN( it ) it 00117 #define F24ASSIGNTHIS *this 00118 00119 // this is one as a fixed24 as a longword 00120 const INT32 FIXED24_ONE = 0x01000000L; 00121 00122 00123 #ifdef FULL_FIXED24 00124 // the following functions are untouched copies from fixed16.cpp 00125 // if you want them, you'll have to convert them to handle FIXED24's 00126 // I've also removed the '>' from the help comments to avoid them being 00127 // compiled into Camelot help 00128 00129 /******************************************************************************************** 00130 00131 static LPTCHAR LongToStringFormat( LPTCHAR p, INT32 value, BOOL leading, BOOL trailing) 00132 00133 Author: Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com> 00134 Created: 12/8/93 00135 Inputs: Pointer to result, INT32 value and flags for leading & trailing spaces 00136 Outputs: Buffer contains up to 5 digits of result 00137 Returns: Returns the updated result pointer 00138 Purpose: Converts low-value INT32s into decimal strings, either ASCII or Unicode 00139 depending on the size of TCHAR. value must be in range 0-999999 inclusive. 00140 Errors: None. 00141 00142 ********************************************************************************************/ 00143 /* Technical Note 00144 As the value can exceed 16-bits a little bit (99,999 is bigger than 65535) all calculations 00145 have to be done using INT32s. This is only a performance problem on 16-bit platforms, so it 00146 doesn't matter 00147 */ 00148 00149 static LPTCHAR LongToStringFormat( LPTCHAR p, INT32 value, BOOL leading, BOOL trailing) 00150 { 00151 INT32 digits = 5; 00152 INT32 tens = 10000L; 00153 00154 while (--digits) 00155 { 00156 if (value >= tens) 00157 { 00158 // we need to output a non-zero digit 00159 00160 *p++ = (TCHAR) ( TEXT('0') + (INT32)(value/tens) ); 00161 value = value % tens; 00162 } 00163 else if (leading) 00164 { 00165 *p++ = TEXT('0'); 00166 } 00167 // stop if zero result and no trailing zeros required 00168 if ( (value==0L) && (!trailing) ) 00169 break; 00170 tens /= 10L; // reduce divisor by 10 00171 } 00172 00173 // final digit easy 00174 *p++ = (TCHAR) ( TEXT('0') + (INT32)value ); 00175 00176 // return next character 00177 return p; 00178 } 00179 00180 /******************************************************************************************** 00181 00182 String FIXED16::ToString() const 00183 00184 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> 00185 Created: 2/6/93 - rewritten in C 12/8/93 by Andy 00186 Inputs: None. 00187 Outputs: None 00188 Returns: Returns a string representing the value of a FIXED16. Optional - sign, up 00189 to five digits of integer, then option period and five fractional digits 00190 then zero terminator (max 13 character result) 00191 Purpose: Converts value of FIXED16 into a string representing it. The string will be 00192 ASCII or Unicode depending on the size of TCHAR 00193 Errors: None. 00194 00195 ********************************************************************************************/ 00196 00197 void fixed16::ToString(String* out) const 00198 { 00199 TCHAR s[13]; 00200 LPTCHAR p = s; 00201 INT32 value = this->all; 00202 00203 if (value < 0L) 00204 { 00205 *p++ = TEXT('-'); // negative values start with a - 00206 value = -value; // ensure result positive 00207 } 00208 00209 // integer part: no leading zeros, trailing zeros 00210 00211 p = LongToStringFormat( p, value >> F16SHIFT, FALSE, FALSE); 00212 00213 value &= 0xFFFF; // get fractional part 00214 00215 if (value) 00216 { 00217 *p++ = TEXT('.'); // decimal point needed 00218 value = MulDiv32By32( value, 100000L, 65536L); // convert fractional part into INT32 00219 00220 // factional part: leading zeros, no trailing 00221 p = LongToStringFormat( p, value, TRUE, FALSE ); 00222 } 00223 00224 *p = (TCHAR)0; // null terminate 00225 00226 *out = s; // convert to proper String 00227 } 00228 #endif // FULL_FIXED24 00229 00230 00231 00232 00233 // Friend Functions - Basic Operators 00234 00235 /******************************************************************************************** 00236 00237 > FIXED24 operator+ (const FIXED24& operand1, const FIXED24& operand2) 00238 00239 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00240 Created: 27/4/93 00241 Friend: FIXED24 00242 Inputs: Two values to be added together. 00243 Outputs: None. 00244 Returns: A FIXED24 with result of addition. 00245 Purpose: Overloading the addition operator for FIXED24s. 00246 Errors: None. 00247 00248 ********************************************************************************************/ 00249 00250 fixed24 operator+ (const fixed24& operand1, const fixed24& operand2) 00251 { 00252 fixed24 result; 00253 00254 result.all = operand1.all + operand2.all; 00255 00256 return result; 00257 } 00258 00259 /******************************************************************************************** 00260 00261 > FIXED24 operator- (const FIXED24& operand1, const FIXED24& operand2) 00262 00263 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00264 Created: 27/4/93 00265 Friend: FIXED24 00266 Inputs: Two values to be subtracted from each other. 00267 Outputs: None. 00268 Returns: A FIXED24 with result of subtraction. 00269 Purpose: Overloading the subtract operator for FIXED24s. 00270 Errors: None. 00271 00272 ********************************************************************************************/ 00273 00274 fixed24 operator- (const fixed24& operand1, const fixed24& operand2) 00275 { 00276 fixed24 result; 00277 00278 result.all = operand1.all - operand2.all; 00279 00280 return result; 00281 } 00282 00283 /******************************************************************************************** 00284 00285 > FIXED24 operator- (const FIXED24& operand1) 00286 00287 Author: Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com> 00288 Created: 30/5/93 00289 Friend: FIXED24 00290 Inputs: A value to be negated. 00291 Outputs: None. 00292 Returns: A FIXED24 with result of negation. 00293 Purpose: Overloading the negation operator for FIXED24s. Should be inline. 00294 Errors: None. 00295 00296 ********************************************************************************************/ 00297 00298 fixed24 operator- (const fixed24& operand) 00299 { 00300 fixed24 temp; 00301 00302 temp.all = -operand.all; 00303 00304 return temp; 00305 } 00306 00307 /******************************************************************************************** 00308 00309 > FIXED24 operator* (const FIXED24& operand1, const FIXED24& operand2) 00310 00311 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00312 Created: 27/4/93 00313 SeeAlso: Fixed24Mul(). 00314 Friend: FIXED24 00315 Inputs: Two values to be multiplied togther. 00316 Outputs: None. 00317 Returns: A FIXED24 with result of multiplication. 00318 Purpose: Overloading the multiplication operator for FIXED24s. 00319 Errors: None. 00320 00321 ********************************************************************************************/ 00322 00323 fixed24 operator* (const fixed24& operand1, const fixed24& operand2) 00324 { 00325 fixed24 result; 00326 00327 F24ASSIGN(result) = Fixed24Mul( operand1, operand2 ); 00328 00329 return result; 00330 } 00331 00332 /******************************************************************************************** 00333 00334 > FIXED24 operator/ (const FIXED24& operand1, const FIXED24& operand2) 00335 00336 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00337 Created: 27/4/93 00338 SeeAlso: Fixed24Div(). 00339 Friend: FIXED24 00340 Inputs: Two values to be divided. 00341 Outputs: None. 00342 Returns: A FIXED24 with result of division. 00343 Purpose: Overloading the division operator for FIXED24s. 00344 Errors: None. 00345 00346 ********************************************************************************************/ 00347 00348 fixed24 operator/ (const fixed24& operand1, const fixed24& operand2) 00349 { 00350 fixed24 result; 00351 00352 F24ASSIGN(result) = Fixed24Div( operand1, operand2 ); 00353 00354 return result; 00355 00356 } 00357 00358 /******************************************************************************************** 00359 00360 > FIXED24& operator>> (const FIXED24& operand1, UINT32 operand2) 00361 00362 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00363 Created: 27/4/93 00364 Friend: FIXED24 00365 Inputs: operand1 - value to be shifted. 00366 operand2 - shift count. 00367 Outputs: None. 00368 Returns: A reference to an FIXED24 with result of ASR. 00369 Purpose: Overloading the >> operator to mean shift right for FIXED24s. 00370 Errors: None. 00371 00372 ********************************************************************************************/ 00373 00374 fixed24 operator>> (const fixed24& operand1, UINT32 operand2) 00375 { 00376 fixed24 result; 00377 00378 result.all = operand1.all >> operand2; 00379 00380 return result; 00381 } 00382 00383 /******************************************************************************************** 00384 00385 > FIXED24 operator>> (const FIXED24& operand1, UINT32 operand2) 00386 00387 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00388 Created: 27/4/93 00389 Friend: FIXED24 00390 Inputs: operand1 - value to be shifted. 00391 operand2 - shift count. 00392 Outputs: None. 00393 Returns: A reference to an FIXED24 with result of ASL. 00394 Purpose: Overloading the << operator to mean shift left for FIXED24s. 00395 Errors: None. 00396 00397 ********************************************************************************************/ 00398 00399 fixed24 operator<< (const fixed24& operand1, UINT32 operand2) 00400 { 00401 fixed24 result; 00402 00403 result.all = operand1.all << operand2; 00404 00405 return result; 00406 } 00407 00408 // Relational operators 00409 00410 /******************************************************************************************** 00411 00412 > INT32 operator== (const FIXED24& operand1, const FIXED24& operand2) 00413 00414 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00415 Created: 5/5/93 00416 Friend: FIXED24 00417 Inputs: Two FIXED24s to be compared. 00418 Outputs: None. 00419 Returns: 0 - False 00420 1 - True 00421 Purpose: Overloading the equality operator for FIXED24s. 00422 Errors: None. 00423 00424 ********************************************************************************************/ 00425 00426 INT32 operator== (const fixed24& operand1, const fixed24& operand2) 00427 { 00428 return operand1.all == operand2.all; 00429 } 00430 00431 /******************************************************************************************** 00432 00433 > INT32 operator== (const FIXED24& operand1, const short operand2) 00434 00435 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00436 Created: 2/6/93 00437 Friend: FIXED24 00438 Inputs: FIXED24 00439 INT8 00440 Outputs: None. 00441 Returns: 0 - False 00442 1 - True 00443 Purpose: Overloading the equality operator for FIXED24s. 00444 Errors: None. 00445 00446 ********************************************************************************************/ 00447 00448 INT32 operator== (const fixed24& operand1, const short operand2) 00449 { 00450 return operand1.all == SHORT_FIXED24( operand2 ); 00451 } 00452 00453 /******************************************************************************************** 00454 00455 > INT32 operator!= (const FIXED24& operand1, const FIXED24& operand2) 00456 00457 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00458 Created: 5/5/93 00459 Friend: FIXED24 00460 Inputs: Two FIXED24s to be compared. 00461 Outputs: None. 00462 Returns: 0 - False 00463 1 - True 00464 Purpose: Overloading the inequality operator for FIXED24s. 00465 Errors: None. 00466 00467 ********************************************************************************************/ 00468 00469 INT32 operator!= (const fixed24& operand1, const fixed24& operand2) 00470 { 00471 return operand1.all != operand2.all; 00472 } 00473 00474 /******************************************************************************************** 00475 00476 > INT32 operator!= (const FIXED24& operand1, const short operand2) 00477 00478 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00479 Created: 5/5/93 00480 Friend: FIXED24 00481 Inputs: FIXED24 00482 short 00483 Outputs: None. 00484 Returns: 0 - False 00485 1 - True 00486 Purpose: Overloading the inequality operator for FIXED24s. 00487 Errors: None. 00488 00489 ********************************************************************************************/ 00490 00491 INT32 operator!= (const fixed24& operand1, const short operand2) 00492 { 00493 return operand1.all != SHORT_FIXED24( operand2 ); 00494 } 00495 00496 /******************************************************************************************** 00497 00498 > INT32 operator> (const FIXED24& operand1, const FIXED24& operand2) 00499 00500 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00501 Created: 5/5/93 00502 Friend: FIXED24 00503 Inputs: Two FIXED24s to be compared. 00504 Outputs: None. 00505 Returns: 0 - False 00506 1 - True 00507 Purpose: Overloading the greater-than operator for FIXED24s. 00508 Errors: None. 00509 00510 ********************************************************************************************/ 00511 00512 INT32 operator> (const fixed24& operand1, const fixed24& operand2) 00513 { 00514 return operand1.all > operand2.all; 00515 } 00516 00517 /******************************************************************************************** 00518 00519 > INT32 operator> (const FIXED24& operand1, const short operand2) 00520 00521 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00522 Created: 5/5/93 00523 Friend: FIXED24 00524 Inputs: FIXED24 00525 short 00526 Outputs: None. 00527 Returns: 0 - False 00528 1 - True 00529 Purpose: Overloading the greater-than operator for FIXED24s. 00530 Errors: None. 00531 00532 ********************************************************************************************/ 00533 00534 INT32 operator> (const fixed24& operand1, const short operand2) 00535 { 00536 return operand1.all > SHORT_FIXED24(operand2); 00537 } 00538 00539 /******************************************************************************************** 00540 00541 > INT32 operator< (const FIXED24& operand1, const FIXED24& operand2) 00542 00543 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00544 Created: 5/5/93 00545 Friend: FIXED24 00546 Inputs: Two FIXED24s to be compared. 00547 Outputs: None. 00548 Returns: 0 - False 00549 1 - True 00550 Purpose: Overloading the less-than operator for FIXED24s. 00551 Errors: None. 00552 00553 ********************************************************************************************/ 00554 00555 INT32 operator< (const fixed24& operand1, const fixed24& operand2) 00556 { 00557 return operand1.all < operand2.all; 00558 } 00559 00560 /******************************************************************************************** 00561 00562 > INT32 operator< (const FIXED24& operand1, const short operand2) 00563 00564 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00565 Created: 5/5/93 00566 Friend: FIXED24 00567 Inputs: FIXED24 00568 short 00569 Outputs: None. 00570 Returns: 0 - False 00571 1 - True 00572 Purpose: Overloading the less-than operator for FIXED24s. 00573 Errors: None. 00574 00575 ********************************************************************************************/ 00576 00577 INT32 operator< (const fixed24& operand1, const short operand2) 00578 { 00579 return operand1.all < SHORT_FIXED24( operand2 ); 00580 } 00581 00582 /******************************************************************************************** 00583 00584 > INT32 operator>= (const FIXED24& operand1, const FIXED24& operand2) 00585 00586 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00587 Created: 5/5/93 00588 Friend: FIXED24 00589 Inputs: Two FIXED24s to be compared. 00590 Outputs: None. 00591 Returns: 0 - False 00592 1 - True 00593 Purpose: Overloading the greater-than-equal-to operator for FIXED24s. 00594 Errors: None. 00595 00596 ********************************************************************************************/ 00597 00598 INT32 operator>= (const fixed24& operand1, const fixed24& operand2) 00599 { 00600 return operand1.all >= operand2.all; 00601 } 00602 00603 /******************************************************************************************** 00604 00605 > INT32 operator>= (const FIXED24& operand1, const short operand2) 00606 00607 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00608 Created: 5/5/93 00609 Friend: FIXED24 00610 Inputs: FIXED24 00611 short 00612 Outputs: None. 00613 Returns: 0 - False 00614 1 - True 00615 Purpose: Overloading the greater-than-equal-to operator for FIXED24s. 00616 Errors: None. 00617 00618 ********************************************************************************************/ 00619 00620 INT32 operator>= (const fixed24& operand1, const short operand2) 00621 { 00622 return operand1.all >= SHORT_FIXED24( operand2 ); 00623 } 00624 00625 /******************************************************************************************** 00626 00627 > INT32 operator<= (const FIXED24& operand1, const FIXED24& operand2) 00628 00629 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00630 Created: 5/5/93 00631 Friend: FIXED24 00632 Inputs: Two FIXED24s to be compared. 00633 Outputs: None. 00634 Returns: 0 - False 00635 1 - True 00636 Purpose: Overloading the less-than-equal-to operator for FIXED24s. 00637 Errors: None. 00638 00639 ********************************************************************************************/ 00640 00641 INT32 operator<= (const fixed24& operand1, const fixed24& operand2) 00642 { 00643 return operand1.all <= operand2.all; 00644 } 00645 00646 /******************************************************************************************** 00647 00648 > INT32 operator<= (const FIXED24& operand1, const short operand2) 00649 00650 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00651 Created: 5/5/93 00652 Friend: FIXED24 00653 Inputs: FIXED24 00654 short 00655 Outputs: None. 00656 Returns: 0 - False 00657 1 - True 00658 Purpose: Overloading the less-than-equal-to operator for FIXED24s. 00659 Errors: None. 00660 00661 ********************************************************************************************/ 00662 00663 INT32 operator<= (const fixed24& operand1, const short operand2) 00664 { 00665 return operand1.all <= SHORT_FIXED24( operand2 ); 00666 } 00667 00668 // Assignment operators 00669 00670 /******************************************************************************************** 00671 00672 > FIXED24& FIXED24::operator= (const INT32 operand) 00673 00674 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00675 Created: 27/4/93 00676 Inputs: operand to be assigned - rhs of assignment. 00677 Outputs: None. 00678 Returns: A reference to an FIXED24 with result of assignment. 00679 Purpose: Overloading the assignment operator for FIXED24s. 00680 Errors: None. 00681 00682 ********************************************************************************************/ 00683 00684 fixed24& fixed24::operator= (const INT32 operand) 00685 { 00686 this->all = SHORT_FIXED24( operand ); 00687 return *this; 00688 } 00689 00690 /******************************************************************************************** 00691 00692 > FIXED24& FIXED24::operator= (const double operand) 00693 00694 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00695 Created: 27/4/93 00696 SeeAlso: DoubleToFixed24(). 00697 Inputs: operand to be assigned - rhs of assignment. 00698 Outputs: None. 00699 Returns: A reference to an FIXED24 with result of assignment. 00700 Purpose: Overloading the assignment operator for FIXED24s. 00701 Errors: None. 00702 00703 ********************************************************************************************/ 00704 00705 fixed24& fixed24::operator= (const double operand) 00706 { 00707 F24ASSIGNTHIS = DoubleToFixed24(operand); 00708 return *this; 00709 } 00710 00711 /******************************************************************************************** 00712 00713 > FIXED24& FIXED24::operator+= (const FIXED24& operand) 00714 00715 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00716 Created: 27/4/93 00717 Inputs: lvalue to be incremented 00718 operand to be added - rhs of assignment. 00719 Outputs: None. 00720 Returns: A reference to an FIXED24 with result of assignment. 00721 Purpose: Overloading the plus-equals operator for FIXED24s. 00722 Errors: None. 00723 00724 ********************************************************************************************/ 00725 00726 fixed24& fixed24::operator+= (const fixed24& operand) 00727 { 00728 this->all += operand.all; 00729 return *this; 00730 } 00731 00732 /******************************************************************************************** 00733 00734 > FIXED24& FIXED24::operator+= (const short operand) 00735 00736 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00737 Created: 27/4/93 00738 Inputs: lvalue to be incremented 00739 operand to be added - rhs of assignment. 00740 Outputs: None. 00741 Returns: A reference to an FIXED24 with result of assignment. 00742 Purpose: Overloading the plus-equals operator for FIXED24s. 00743 Errors: None. 00744 00745 ********************************************************************************************/ 00746 00747 fixed24& fixed24::operator+= (const short operand) 00748 { 00749 this->all += SHORT_FIXED24( operand ); 00750 return *this; 00751 } 00752 00753 /******************************************************************************************** 00754 00755 > FIXED24& FIXED24::operator-= (const FIXED24& operand) 00756 00757 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00758 Created: 27/4/93 00759 Inputs: lvalue to be decremented 00760 operand to be subtracted - rhs of assignment. 00761 Outputs: None. 00762 Returns: A reference to an FIXED24 with result of assignment. 00763 Purpose: Overloading the minus-equals operator for FIXED24s. 00764 Errors: None. 00765 00766 ********************************************************************************************/ 00767 00768 fixed24& fixed24::operator-= (const fixed24& operand) 00769 { 00770 this->all -= operand.all; 00771 return *this; 00772 } 00773 00774 /******************************************************************************************** 00775 00776 > FIXED24& FIXED24::operator-= (const short operand) 00777 00778 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00779 Created: 27/4/93 00780 Inputs: lvalue to be decremented 00781 operand to be subtracted - rhs of assignment. 00782 Outputs: None. 00783 Returns: A reference to an FIXED24 with result of assignment. 00784 Purpose: Overloading the minus-equals operator for FIXED24s. 00785 Errors: None. 00786 00787 ********************************************************************************************/ 00788 00789 fixed24& fixed24::operator-= (const short operand) 00790 { 00791 this->all -= SHORT_FIXED24( operand ); 00792 return *this; 00793 } 00794 00795 /******************************************************************************************** 00796 00797 > FIXED24& FIXED24::operator*= (const FIXED24& operand) 00798 00799 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00800 Created: 27/4/93 00801 SeeAlso: Fixed24Mul(). 00802 Inputs: lvalue to be multiplied 00803 multiplier - rhs of assignment. 00804 Outputs: None. 00805 Returns: A reference to an FIXED24 with result of assignment. 00806 Purpose: Overloading the times-equals operator for FIXED24s. 00807 Errors: None. 00808 00809 ********************************************************************************************/ 00810 00811 fixed24& fixed24::operator*= (const fixed24& operand) 00812 { 00813 F24ASSIGNTHIS = Fixed24Mul(*this, operand); 00814 00815 return *this; 00816 } 00817 00818 /******************************************************************************************** 00819 00820 > FIXED24& FIXED24::operator*= (const short operand) 00821 00822 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00823 Created: 27/4/93 00824 SeeAlso: Fixed24Mul(). 00825 Inputs: lvalue to be multiplied 00826 multiplier - rhs of assignment. 00827 Outputs: None. 00828 Returns: A reference to an FIXED24 with result of assignment. 00829 Purpose: Overloading the times-equals operator for FIXED24s. 00830 Errors: None. 00831 00832 ********************************************************************************************/ 00833 00834 fixed24& fixed24::operator*= (const short operand) 00835 { 00836 fixed24 temp; 00837 00838 temp.all = SHORT_FIXED24( operand ); 00839 00840 F24ASSIGNTHIS = Fixed24Mul(*this, temp); 00841 00842 return *this; 00843 } 00844 00845 /******************************************************************************************** 00846 00847 > FIXED24& FIXED24::operator/= (const FIXED24& operand) 00848 00849 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00850 Created: 27/4/93 00851 SeeAlso: Fixed24Div(). 00852 Inputs: lvalue to be divided 00853 divisor - rhs of assignment. 00854 Outputs: None. 00855 Returns: A reference to an FIXED24 with result of assignment. 00856 Purpose: Overloading the divide-equals operator for FIXED24s. 00857 Errors: None. 00858 00859 ********************************************************************************************/ 00860 00861 fixed24& fixed24::operator/= (const fixed24& operand) 00862 { 00863 F24ASSIGNTHIS = Fixed24Div(*this, operand); 00864 00865 return *this; 00866 } 00867 00868 /******************************************************************************************** 00869 00870 > FIXED24& FIXED24::operator/= (const short operand) 00871 00872 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00873 Created: 27/4/93 00874 SeeAlso: Fixed24Div(). 00875 Inputs: lvalue to be divided 00876 divisor - rhs of assignment. 00877 Outputs: None. 00878 Returns: A reference to an FIXED24 with result of assignment. 00879 Purpose: Overloading the divide-equals operator for FIXED24s. 00880 Errors: None. 00881 00882 ********************************************************************************************/ 00883 00884 fixed24& fixed24::operator/= (const short operand) 00885 { 00886 fixed24 temp; 00887 00888 temp.all = SHORT_FIXED24( operand ); 00889 00890 F24ASSIGNTHIS = Fixed24Div(*this, temp); 00891 00892 return *this; 00893 } 00894 00895 /******************************************************************************************** 00896 00897 > FIXED24& FIXED24::operator<<= (const UINT32 operand) 00898 00899 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00900 Created: 27/4/93 00901 Inputs: lvalue to be shifted 00902 shift count - rhs of assignment. 00903 Outputs: None. 00904 Returns: A reference to an FIXED24 with result of assignment. 00905 Purpose: Overloading the left-shift-equals operator for FIXED24s. 00906 Errors: None. 00907 00908 ********************************************************************************************/ 00909 00910 fixed24& fixed24::operator<<= (const UINT32 operand) 00911 { 00912 this->all <<= operand; 00913 return *this; 00914 } 00915 00916 /******************************************************************************************** 00917 00918 > FIXED24& FIXED24::operator>>= (const UINT32 operand) 00919 00920 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00921 Created: 27/4/93 00922 Inputs: lvalue to be shifted 00923 shift count - rhs of assignment. 00924 Outputs: None. 00925 Returns: A reference to an FIXED24 with result of assignment. 00926 Purpose: Overloading the right-shift-equals operator for FIXED24s. 00927 Errors: None. 00928 00929 ********************************************************************************************/ 00930 00931 fixed24& fixed24::operator>>= (const UINT32 operand) 00932 { 00933 this->all >>= operand; 00934 return *this; 00935 } 00936 00937 // Increment FIXED24::operators 00938 00939 /******************************************************************************************** 00940 00941 > FIXED24& FIXED24::operator++ () 00942 00943 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00944 Created: 27/4/93 00945 Inputs: None. 00946 Outputs: None. 00947 Returns: A reference to an FIXED24 with result of increment. 00948 Purpose: Overloading the prefix plus-plus operator for FIXED24s. 00949 Errors: None. 00950 00951 ********************************************************************************************/ 00952 00953 fixed24& fixed24::operator++ () // prefix 00954 { 00955 this->all += FIXED24_ONE; 00956 return *this; 00957 } 00958 00959 /******************************************************************************************** 00960 00961 > FIXED24 FIXED24::operator++ (INT32 dummy) 00962 00963 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00964 Created: 27/4/93 00965 Inputs: dummy value to distinguish between pre- and post-fix application. 00966 Outputs: None. 00967 Returns: A reference to an FIXED24 with result of increment. 00968 Purpose: Overloading the postfix plus-plus operator for FIXED24s. 00969 Errors: None. 00970 00971 ********************************************************************************************/ 00972 00973 fixed24 fixed24::operator++ (INT32 dummy) // postfix 00974 { 00975 fixed24 result = *this; 00976 00977 this->all += FIXED24_ONE; 00978 00979 return result; 00980 } 00981 00982 /******************************************************************************************** 00983 00984 > FIXED24& FIXED24::operator-- () 00985 00986 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 00987 Created: 27/4/93 00988 Inputs: None. 00989 Outputs: None. 00990 Returns: A reference to an FIXED24 with result of decrement. 00991 Purpose: Overloading the prefix minus-minus operator for FIXED24s. 00992 Errors: None. 00993 00994 ********************************************************************************************/ 00995 00996 fixed24& fixed24::operator-- () // prefix 00997 { 00998 this->all -= FIXED24_ONE; 00999 return *this; 01000 } 01001 01002 /******************************************************************************************** 01003 01004 > FIXED24 FIXED24::operator-- (INT32 dummy) 01005 01006 Author: Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com> (Jason Williams) 01007 Created: 27/4/93 01008 Inputs: dummy value to distinguish between pre- and post-fix application. 01009 Outputs: None. 01010 Returns: A reference to an FIXED24 with result of decrement. 01011 Purpose: Overloading the postfix minus-minus operator for FIXED24s. 01012 Errors: None. 01013 01014 ********************************************************************************************/ 01015 01016 fixed24 fixed24::operator-- (INT32 dummy) // postfix 01017 { 01018 fixed24 result = *this; 01019 01020 this->all -= FIXED24_ONE; 01021 01022 return result; 01023 } 01024