1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
|
/*
This file is part of the Boson game
Copyright (C) 2004-2005 Andreas Beckermann (b_mann@gmx.de)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
// note the copyright above: this is LGPL!
#ifndef BOFIXED_H
#define BOFIXED_H
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <qglobal.h> // Q_INT32, ...
// Define this when you want bofixed to use normal floats (so that essentially
// bofixed = float)
//#define BOFIXED_IS_FLOAT
// we have 32 bits available, the bits before the decimal point are responible
// for how large the numbers can be (10 bits mean up to 2^(10-1)-1). the bits
// after the decimal point are responsible for how precise we are.
// AB: i believe 15 bits before the point are sufficient for boson, since
// canvas/world/cell coordinates are always <= 500. 15 bits support numbers up
// to 16383.
#define BITS_AFTER_POINT (32-15)
// 2^(BITS_AFTER_POINT) -> this is required for float conversion which doesn't
// like shifting. multiplying by BITS_POW is equal to shifting left by
// BITS_AFTER_POINT.
#define BITS_POW (0x1<<BITS_AFTER_POINT)
// AB: on fixed point arithmetics:
// conversion from/to int is easy - just shift to the left/right by the number
// of bits after (!) the point.
// addition is easy in fixed point arithmetics, as we can use usual int addition.
// subtraction is trivial (negative addition).
// multiplication and division however need a bit more work. the cpu "sees"
// BITS_AFTER_POINT additional digits that have no actual meaning. e.g. we have
// "010.00" for a 5 bit type with 2 bits after the point. this is a decimal 2,
// but interpreted as an int it's a 8. square this number and we should get 4
// (i.e. "100.00"), but what we get is "10000.00", which needs more than our 5
// bits and is obviously not the correct value. we can fix that by shifting
// back by BITS_AFTER_POINT bits, however we need a type that can take all the
// bits temporarily (64 bits, as we use 32 bits in bofixed) before we shift.
/**
* @short A fixed point type
*
* This class is a replacement for the standard float datatype. It uses fixed
* point arithmetic (float and double use floating point arithmetics) and is
* based on integer calculations, therefore the results of the calculations are
* not dependand on the FPU of your computer. This is necessary because boson
* often depends on the clients to calculate exactly the same values, however
* when using floating point calculations this is not always the case (although
* all FPUs involved are IEEE complient).
*
* The bofixed class is meant to be used like any other type, in particular it
* should be used a simple drop in replacement for floats. You should be able to
* just replace the declaration of "float" by "bofixed".
*
* Most of this class consists of overloading operators for the different types.
* Therefore you should easily be able to do things like
* <pre>
* float a = my_value;
* bofixed b = ma_2nd_value;
* b += a;
* b += 0.15f;
* b += (int)10
* </pre>
* without explicitly converting values to bofixed.
*
* @author Andreas Beckermann <b_mann@gmx.de>
**/
#ifndef BOFIXED_IS_FLOAT
class bofixed
{
public:
/**
* Construct a fixed point variable with initial value 0.0
**/
bofixed()
: mValue(0)
{
}
bofixed(const bofixed& f)
: mValue(f.mValue)
{
}
bofixed(Q_INT32 f) : mValue(f << BITS_AFTER_POINT) { }
bofixed(Q_UINT32 f) : mValue(f << BITS_AFTER_POINT) { }
bofixed(Q_INT8 f) : mValue(((Q_INT32)f) << BITS_AFTER_POINT) { }
bofixed(Q_UINT8 f) : mValue(((Q_INT32)f) << BITS_AFTER_POINT) { }
bofixed(Q_INT16 f) : mValue(((Q_INT32)f) << BITS_AFTER_POINT) { }
bofixed(Q_UINT16 f) : mValue(((Q_INT32)f) << BITS_AFTER_POINT) { }
bofixed(Q_LONG f) : mValue(((Q_INT32)f) << BITS_AFTER_POINT) { }
bofixed(Q_ULONG f) : mValue(((Q_INT32)f) << BITS_AFTER_POINT) { }
bofixed(float f) : mValue((Q_INT32)(nearbyintf(f * BITS_POW))) { }
bofixed(double f) : mValue((Q_INT32)(nearbyintf(f * BITS_POW))) { }
inline bool equals(const bofixed& f) const { return (mValue == f.mValue); }
inline bool isGreater(const bofixed& f) const { return (mValue > f.mValue); }
inline bool isGreaterEqual(const bofixed& f) const { return (mValue >= f.mValue); }
inline bool isLess(const bofixed& f) const { return (mValue < f.mValue); }
inline bool isLessEqual(const bofixed& f) const { return (mValue <= f.mValue); }
/**
* @return The fixed point value castet to integer. This behaves just
* like casting a floating point number to int, i.e. the digits after
* the decimal point are "cut off".
**/
inline Q_INT32 toInt() const { return mValue >> BITS_AFTER_POINT; }
inline float toFloat() const { return ((float)mValue) / BITS_POW; }
inline double toDouble() const { return (double)toFloat(); }
/**
* @return The internal representation of the fixed point value. This
* may be useful for debugging-
**/
Q_INT32 rawInt() const { return mValue; }
void setFromRawInt(Q_INT32 r) { mValue = r; }
bofixed& operator=(const bofixed& f) { mValue = f.mValue; return *this; }
bofixed& operator=(Q_INT32 f) { mValue = f << BITS_AFTER_POINT; return *this; }
bofixed& operator=(Q_UINT32 f) { mValue = f << BITS_AFTER_POINT; return *this; }
bofixed& operator=(Q_INT8 f) { mValue = ((Q_INT32)f) << BITS_AFTER_POINT; return *this; }
bofixed& operator=(Q_UINT8 f) { mValue = ((Q_INT32)f) << BITS_AFTER_POINT; return *this; }
bofixed& operator=(Q_INT16 f) { mValue = f << BITS_AFTER_POINT; return *this; }
bofixed& operator=(Q_UINT16 f) { mValue = f << BITS_AFTER_POINT; return *this; }
bofixed& operator=(Q_LONG f) { mValue = f << BITS_AFTER_POINT; return *this; }
bofixed& operator=(Q_ULONG f) { mValue = f << BITS_AFTER_POINT; return *this; }
bofixed& operator=(float f) { mValue = (Q_INT32)(nearbyintf(f * BITS_POW)); return *this; }
bofixed& operator=(double f) { mValue = (Q_INT32)(nearbyintf(f * BITS_POW)); return *this; }
inline operator float() const { return toFloat(); }
// AB: providing dedicated casting operators for several types is _not_
// a good idea. for example things like if (!x) where x is a bofixed
// causes a compiler error, as g++ doesn't know what to cast to (since
// unless we would provide a bool cast operator, too).
// providing float only means that if (!x) does exactly what we would
// expect.
//
// disadvantage: things like domElement.setAttribute("x", x) work
// without changes - we store a float here. I believe it would be nicer
// if we'd store bofixed as a rawInt() in xml files.
inline bofixed operator-() const { bofixed f(*this); f.mValue *= -1; return f; }
inline bofixed& operator+=(const bofixed& f) { mValue += f.mValue; return *this; }
inline bofixed& operator+=(Q_INT32 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_UINT32 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_INT16 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_UINT16 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_INT8 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_UINT8 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_LONG f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_ULONG f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(float f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(double f) { return operator+=(bofixed(f)); }
inline bofixed& operator-=(const bofixed& f) { mValue -= f.mValue; return *this; }
inline bofixed& operator-=(Q_INT32 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_UINT32 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_INT16 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_UINT16 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_INT8 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_UINT8 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_LONG f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_ULONG f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(float f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(double f) { return operator-=(bofixed(f)); }
inline bofixed& operator*=(const bofixed& f)
{
Q_INT64 tmp = ((Q_INT64)mValue) * f.mValue;
mValue = (tmp >> BITS_AFTER_POINT);
return *this;
}
inline bofixed& operator*=(Q_INT32 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_UINT32 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_INT16 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_UINT16 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_INT8 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_UINT8 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_LONG f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_ULONG f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(float f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(double f) { return operator*=(bofixed(f)); }
inline bofixed& operator/=(const bofixed& f)
{
// AB: the result of mValue/f.mValue must be shifted left by
// BITS_AFTER_POINT bits. however that would mean losing a lot
// of precision, so instead we shift the value that we divide to
// the right first.
Q_INT64 tmp = ((Q_INT64)mValue) << BITS_AFTER_POINT;
tmp /= f.mValue;
mValue = tmp;
return *this;
}
inline bofixed& operator/=(Q_INT32 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_UINT32 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_INT16 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_UINT16 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_INT8 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_UINT8 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_LONG f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_ULONG f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(float f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(double f) { return operator/=(bofixed(f)); }
private:
Q_INT32 mValue;
};
#else
class bofixed
{
public:
/**
* Construct a fixed point variable with initial value 0.0
**/
bofixed()
: mValue(0.0f)
{
}
bofixed(const bofixed& f)
: mValue(f.mValue)
{
}
bofixed(Q_INT32 f) : mValue(f) { }
bofixed(Q_UINT32 f) : mValue(f) { }
bofixed(Q_INT8 f) : mValue(f) { }
bofixed(Q_UINT8 f) : mValue(f) { }
bofixed(Q_INT16 f) : mValue(f) { }
bofixed(Q_UINT16 f) : mValue(f) { }
bofixed(Q_LONG f) : mValue(f) { }
bofixed(Q_ULONG f) : mValue(f) { }
bofixed(float f) : mValue(f) { }
bofixed(double f) : mValue(f) { }
inline bool equals(const bofixed& f) const { return (mValue == f.mValue); }
inline bool isGreater(const bofixed& f) const { return (mValue > f.mValue); }
inline bool isGreaterEqual(const bofixed& f) const { return (mValue >= f.mValue); }
inline bool isLess(const bofixed& f) const { return (mValue < f.mValue); }
inline bool isLessEqual(const bofixed& f) const { return (mValue <= f.mValue); }
/**
* @return The fixed point value castet to integer. This behaves just
* like casting a floating point number to int, i.e. the digits after
* the decimal point are "cut off".
**/
inline Q_INT32 toInt() const { return (Q_INT32)mValue; }
inline float toFloat() const { return mValue; }
inline double toDouble() const { return (double)mValue; }
/**
* @return The internal representation of the fixed point value. This
* may be useful for debugging-
**/
Q_INT32 rawInt() const { return *((Q_UINT32*)&mValue); }
void setFromRawInt(Q_INT32 r) { mValue = *((float*)&r); }
bofixed& operator=(const bofixed& f) { mValue = f.mValue; return *this; }
bofixed& operator=(Q_INT32 f) { mValue = f; return *this; }
bofixed& operator=(Q_UINT32 f) { mValue = f; return *this; }
bofixed& operator=(Q_INT8 f) { mValue = f; return *this; }
bofixed& operator=(Q_UINT8 f) { mValue = f; return *this; }
bofixed& operator=(Q_INT16 f) { mValue = f; return *this; }
bofixed& operator=(Q_UINT16 f) { mValue = f; return *this; }
bofixed& operator=(Q_LONG f) { mValue = f; return *this; }
bofixed& operator=(Q_ULONG f) { mValue = f; return *this; }
bofixed& operator=(float f) { mValue = f; return *this; }
bofixed& operator=(double f) { mValue = f; return *this; }
inline operator float() const { return toFloat(); }
// AB: providing dedicated casting operators for several types is _not_
// a good idea. for example things like if (!x) where x is a bofixed
// causes a compiler error, as g++ doesn't know what to cast to (since
// unless we would provide a bool cast operator, too).
// providing float only means that if (!x) does exactly what we would
// expect.
//
// disadvantage: things like domElement.setAttribute("x", x) work
// without changes - we store a float here. I believe it would be nicer
// if we'd store bofixed as a rawInt() in xml files.
inline bofixed operator-() const { bofixed f(*this); f.mValue *= -1; return f; }
inline bofixed& operator+=(const bofixed& f) { mValue += f.mValue; return *this; }
inline bofixed& operator+=(Q_INT32 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_UINT32 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_INT16 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_UINT16 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_INT8 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_UINT8 f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_LONG f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(Q_ULONG f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(float f) { return operator+=(bofixed(f)); }
inline bofixed& operator+=(double f) { return operator+=(bofixed(f)); }
inline bofixed& operator-=(const bofixed& f) { mValue -= f.mValue; return *this; }
inline bofixed& operator-=(Q_INT32 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_UINT32 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_INT16 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_UINT16 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_INT8 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_UINT8 f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_LONG f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(Q_ULONG f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(float f) { return operator-=(bofixed(f)); }
inline bofixed& operator-=(double f) { return operator-=(bofixed(f)); }
inline bofixed& operator*=(const bofixed& f)
{
mValue *= f.mValue;
return *this;
}
inline bofixed& operator*=(Q_INT32 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_UINT32 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_INT16 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_UINT16 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_INT8 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_UINT8 f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_LONG f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(Q_ULONG f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(float f) { return operator*=(bofixed(f)); }
inline bofixed& operator*=(double f) { return operator*=(bofixed(f)); }
inline bofixed& operator/=(const bofixed& f)
{
mValue /= f.mValue;
return *this;
}
inline bofixed& operator/=(Q_INT32 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_UINT32 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_INT16 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_UINT16 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_INT8 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_UINT8 f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_LONG f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(Q_ULONG f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(float f) { return operator/=(bofixed(f)); }
inline bofixed& operator/=(double f) { return operator/=(bofixed(f)); }
private:
float mValue;
};
#endif
inline bofixed operator+(const bofixed& f1, const bofixed& f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(const bofixed& f1, Q_INT32 f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(const bofixed& f1, Q_UINT32 f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(const bofixed& f1, Q_INT16 f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(const bofixed& f1, Q_UINT16 f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(const bofixed& f1, Q_INT8 f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(const bofixed& f1, Q_UINT8 f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(const bofixed& f1, Q_LONG f2 ) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(const bofixed& f1, Q_ULONG f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(const bofixed& f1, float f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(const bofixed& f1, double f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(Q_INT32 f1, const bofixed& f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(Q_UINT32 f1, const bofixed& f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(Q_INT8 f1, const bofixed& f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(Q_UINT8 f1, const bofixed& f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(Q_INT16 f1, const bofixed& f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(Q_UINT16 f1, const bofixed& f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(Q_LONG f1, const bofixed& f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(Q_ULONG f1, const bofixed& f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(float f1, const bofixed& f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator+(double f1, const bofixed& f2) { bofixed f(f1); f += f2; return f; }
inline bofixed operator-(const bofixed& f1, const bofixed& f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(const bofixed& f1, Q_INT32 f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(const bofixed& f1, Q_UINT32 f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(const bofixed& f1, Q_INT16 f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(const bofixed& f1, Q_UINT16 f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(const bofixed& f1, Q_INT8 f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(const bofixed& f1, Q_UINT8 f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(const bofixed& f1, Q_LONG f2 ) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(const bofixed& f1, Q_ULONG f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(const bofixed& f1, float f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(const bofixed& f1, double f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(Q_INT32 f1, const bofixed& f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(Q_UINT32 f1, const bofixed& f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(Q_INT8 f1, const bofixed& f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(Q_UINT8 f1, const bofixed& f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(Q_INT16 f1, const bofixed& f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(Q_UINT16 f1, const bofixed& f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(Q_LONG f1, const bofixed& f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(Q_ULONG f1, const bofixed& f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(float f1, const bofixed& f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator-(double f1, const bofixed& f2) { bofixed f(f1); f -= f2; return f; }
inline bofixed operator*(const bofixed& f1, const bofixed& f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(const bofixed& f1, Q_INT32 f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(const bofixed& f1, Q_UINT32 f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(const bofixed& f1, Q_INT16 f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(const bofixed& f1, Q_UINT16 f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(const bofixed& f1, Q_INT8 f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(const bofixed& f1, Q_UINT8 f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(const bofixed& f1, Q_LONG f2 ) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(const bofixed& f1, Q_ULONG f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(const bofixed& f1, float f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(const bofixed& f1, double f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(Q_INT32 f1, const bofixed& f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(Q_UINT32 f1, const bofixed& f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(Q_INT8 f1, const bofixed& f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(Q_UINT8 f1, const bofixed& f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(Q_INT16 f1, const bofixed& f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(Q_UINT16 f1, const bofixed& f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(Q_LONG f1, const bofixed& f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(Q_ULONG f1, const bofixed& f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(float f1, const bofixed& f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator*(double f1, const bofixed& f2) { bofixed f(f1); f *= f2; return f; }
inline bofixed operator/(const bofixed& f1, const bofixed& f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(const bofixed& f1, Q_INT32 f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(const bofixed& f1, Q_UINT32 f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(const bofixed& f1, Q_INT16 f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(const bofixed& f1, Q_UINT16 f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(const bofixed& f1, Q_INT8 f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(const bofixed& f1, Q_UINT8 f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(const bofixed& f1, Q_LONG f2 ) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(const bofixed& f1, Q_ULONG f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(const bofixed& f1, float f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(const bofixed& f1, double f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(Q_INT32 f1, const bofixed& f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(Q_UINT32 f1, const bofixed& f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(Q_INT8 f1, const bofixed& f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(Q_UINT8 f1, const bofixed& f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(Q_INT16 f1, const bofixed& f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(Q_UINT16 f1, const bofixed& f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(Q_LONG f1, const bofixed& f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(Q_ULONG f1, const bofixed& f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(float f1, const bofixed& f2) { bofixed f(f1); f /= f2; return f; }
inline bofixed operator/(double f1, const bofixed& f2) { bofixed f(f1); f /= f2; return f; }
inline bool operator==(const bofixed& f1, const bofixed& f2) { return f1.equals(f2); }
inline bool operator==(const bofixed& f1, Q_INT32 f2) { return f1.equals(bofixed(f2)); }
inline bool operator==(const bofixed& f1, Q_UINT32 f2) { return f1.equals(bofixed(f2)); }
inline bool operator==(const bofixed& f1, Q_INT16 f2) { return f1.equals(bofixed(f2)); }
inline bool operator==(const bofixed& f1, Q_UINT16 f2) { return f1.equals(bofixed(f2)); }
inline bool operator==(const bofixed& f1, Q_INT8 f2) { return f1.equals(bofixed(f2)); }
inline bool operator==(const bofixed& f1, Q_UINT8 f2) { return f1.equals(bofixed(f2)); }
inline bool operator==(const bofixed& f1, Q_LONG f2) { return f1.equals(bofixed(f2)); }
inline bool operator==(const bofixed& f1, Q_ULONG f2) { return f1.equals(bofixed(f2)); }
inline bool operator==(const bofixed& f1, float f2) { return f1.equals(bofixed(f2)); }
inline bool operator==(const bofixed& f1, double f2) { return f1.equals(bofixed(f2)); }
inline bool operator==(Q_INT32 f1, const bofixed& f2) { return bofixed(f1).equals(f2); }
inline bool operator==(Q_UINT32 f1, const bofixed& f2) { return bofixed(f1).equals(f2); }
inline bool operator==(Q_INT16 f1, const bofixed& f2) { return bofixed(f1).equals(f2); }
inline bool operator==(Q_UINT16 f1, const bofixed& f2) { return bofixed(f1).equals(f2); }
inline bool operator==(Q_INT8 f1, const bofixed& f2) { return bofixed(f1).equals(f2); }
inline bool operator==(Q_UINT8 f1, const bofixed& f2) { return bofixed(f1).equals(f2); }
inline bool operator==(Q_LONG f1, const bofixed& f2) { return bofixed(f1).equals(f2); }
inline bool operator==(Q_ULONG f1, const bofixed& f2) { return bofixed(f1).equals(f2); }
inline bool operator==(float f1, const bofixed& f2) { return bofixed(f1).equals(f2); }
inline bool operator==(double f1, const bofixed& f2) { return bofixed(f1).equals(f2); }
inline bool operator!=(const bofixed& f1, const bofixed& f2) { return !f1.equals(f2); }
inline bool operator!=(const bofixed& f1, Q_INT32 f2) { return !f1.equals(bofixed(f2)); }
inline bool operator!=(const bofixed& f1, Q_UINT32 f2) { return !f1.equals(bofixed(f2)); }
inline bool operator!=(const bofixed& f1, Q_INT16 f2) { return !f1.equals(bofixed(f2)); }
inline bool operator!=(const bofixed& f1, Q_UINT16 f2) { return !f1.equals(bofixed(f2)); }
inline bool operator!=(const bofixed& f1, Q_INT8 f2) { return !f1.equals(bofixed(f2)); }
inline bool operator!=(const bofixed& f1, Q_UINT8 f2) { return !f1.equals(bofixed(f2)); }
inline bool operator!=(const bofixed& f1, Q_LONG f2) { return !f1.equals(bofixed(f2)); }
inline bool operator!=(const bofixed& f1, Q_ULONG f2) { return !f1.equals(bofixed(f2)); }
inline bool operator!=(const bofixed& f1, float f2) { return !f1.equals(bofixed(f2)); }
inline bool operator!=(const bofixed& f1, double f2) { return !f1.equals(bofixed(f2)); }
inline bool operator!=(Q_INT32 f1, const bofixed& f2) { return !bofixed(f1).equals(f2); }
inline bool operator!=(Q_UINT32 f1, const bofixed& f2) { return !bofixed(f1).equals(f2); }
inline bool operator!=(Q_INT16 f1, const bofixed& f2) { return !bofixed(f1).equals(f2); }
inline bool operator!=(Q_UINT16 f1, const bofixed& f2) { return !bofixed(f1).equals(f2); }
inline bool operator!=(Q_INT8 f1, const bofixed& f2) { return !bofixed(f1).equals(f2); }
inline bool operator!=(Q_UINT8 f1, const bofixed& f2) { return !bofixed(f1).equals(f2); }
inline bool operator!=(Q_LONG f1, const bofixed& f2) { return !bofixed(f1).equals(f2); }
inline bool operator!=(Q_ULONG f1, const bofixed& f2) { return !bofixed(f1).equals(f2); }
inline bool operator!=(float f1, const bofixed& f2) { return !bofixed(f1).equals(f2); }
inline bool operator!=(double f1, const bofixed& f2) { return !bofixed(f1).equals(f2); }
inline bool operator<=(const bofixed& f1, const bofixed& f2) { return f1.isLessEqual(f2); }
inline bool operator<=(const bofixed& f1, Q_INT32 f2) { return f1.isLessEqual(bofixed(f2)); }
inline bool operator<=(const bofixed& f1, Q_UINT32 f2) { return f1.isLessEqual(bofixed(f2)); }
inline bool operator<=(const bofixed& f1, Q_INT16 f2) { return f1.isLessEqual(bofixed(f2)); }
inline bool operator<=(const bofixed& f1, Q_UINT16 f2) { return f1.isLessEqual(bofixed(f2)); }
inline bool operator<=(const bofixed& f1, Q_INT8 f2) { return f1.isLessEqual(bofixed(f2)); }
inline bool operator<=(const bofixed& f1, Q_UINT8 f2) { return f1.isLessEqual(bofixed(f2)); }
inline bool operator<=(const bofixed& f1, Q_LONG f2) { return f1.isLessEqual(bofixed(f2)); }
inline bool operator<=(const bofixed& f1, Q_ULONG f2) { return f1.isLessEqual(bofixed(f2)); }
inline bool operator<=(const bofixed& f1, float f2) { return f1.isLessEqual(bofixed(f2)); }
inline bool operator<=(const bofixed& f1, double f2) { return f1.isLessEqual(bofixed(f2)); }
inline bool operator<=(Q_INT32 f1, const bofixed& f2) { return bofixed(f1).isLessEqual(f2); }
inline bool operator<=(Q_UINT32 f1, const bofixed& f2) { return bofixed(f1).isLessEqual(f2); }
inline bool operator<=(Q_INT16 f1, const bofixed& f2) { return bofixed(f1).isLessEqual(f2); }
inline bool operator<=(Q_UINT16 f1, const bofixed& f2) { return bofixed(f1).isLessEqual(f2); }
inline bool operator<=(Q_INT8 f1, const bofixed& f2) { return bofixed(f1).isLessEqual(f2); }
inline bool operator<=(Q_UINT8 f1, const bofixed& f2) { return bofixed(f1).isLessEqual(f2); }
inline bool operator<=(Q_LONG f1, const bofixed& f2) { return bofixed(f1).isLessEqual(f2); }
inline bool operator<=(Q_ULONG f1, const bofixed& f2) { return bofixed(f1).isLessEqual(f2); }
inline bool operator<=(float f1, const bofixed& f2) { return bofixed(f1).isLessEqual(f2); }
inline bool operator<=(double f1, const bofixed& f2) { return bofixed(f1).isLessEqual(f2); }
inline bool operator>=(const bofixed& f1, const bofixed& f2) { return f1.isGreaterEqual(f2); }
inline bool operator>=(const bofixed& f1, Q_INT32 f2) { return f1.isGreaterEqual(bofixed(f2)); }
inline bool operator>=(const bofixed& f1, Q_UINT32 f2) { return f1.isGreaterEqual(bofixed(f2)); }
inline bool operator>=(const bofixed& f1, Q_INT16 f2) { return f1.isGreaterEqual(bofixed(f2)); }
inline bool operator>=(const bofixed& f1, Q_UINT16 f2) { return f1.isGreaterEqual(bofixed(f2)); }
inline bool operator>=(const bofixed& f1, Q_INT8 f2) { return f1.isGreaterEqual(bofixed(f2)); }
inline bool operator>=(const bofixed& f1, Q_UINT8 f2) { return f1.isGreaterEqual(bofixed(f2)); }
inline bool operator>=(const bofixed& f1, Q_LONG f2) { return f1.isGreaterEqual(bofixed(f2)); }
inline bool operator>=(const bofixed& f1, Q_ULONG f2) { return f1.isGreaterEqual(bofixed(f2)); }
inline bool operator>=(const bofixed& f1, float f2) { return f1.isGreaterEqual(bofixed(f2)); }
inline bool operator>=(const bofixed& f1, double f2) { return f1.isGreaterEqual(bofixed(f2)); }
inline bool operator>=(Q_INT32 f1, const bofixed& f2) { return bofixed(f1).isGreaterEqual(f2); }
inline bool operator>=(Q_UINT32 f1, const bofixed& f2) { return bofixed(f1).isGreaterEqual(f2); }
inline bool operator>=(Q_INT16 f1, const bofixed& f2) { return bofixed(f1).isGreaterEqual(f2); }
inline bool operator>=(Q_UINT16 f1, const bofixed& f2) { return bofixed(f1).isGreaterEqual(f2); }
inline bool operator>=(Q_INT8 f1, const bofixed& f2) { return bofixed(f1).isGreaterEqual(f2); }
inline bool operator>=(Q_UINT8 f1, const bofixed& f2) { return bofixed(f1).isGreaterEqual(f2); }
inline bool operator>=(Q_LONG f1, const bofixed& f2) { return bofixed(f1).isGreaterEqual(f2); }
inline bool operator>=(Q_ULONG f1, const bofixed& f2) { return bofixed(f1).isGreaterEqual(f2); }
inline bool operator>=(float f1, const bofixed& f2) { return bofixed(f1).isGreaterEqual(f2); }
inline bool operator>=(double f1, const bofixed& f2) { return bofixed(f1).isGreaterEqual(f2); }
inline bool operator<(const bofixed& f1, const bofixed& f2) { return f1.isLess(f2); }
inline bool operator<(const bofixed& f1, Q_INT32 f2) { return f1.isLess(bofixed(f2)); }
inline bool operator<(const bofixed& f1, Q_UINT32 f2) { return f1.isLess(bofixed(f2)); }
inline bool operator<(const bofixed& f1, Q_INT16 f2) { return f1.isLess(bofixed(f2)); }
inline bool operator<(const bofixed& f1, Q_UINT16 f2) { return f1.isLess(bofixed(f2)); }
inline bool operator<(const bofixed& f1, Q_INT8 f2) { return f1.isLess(bofixed(f2)); }
inline bool operator<(const bofixed& f1, Q_UINT8 f2) { return f1.isLess(bofixed(f2)); }
inline bool operator<(const bofixed& f1, Q_LONG f2) { return f1.isLess(bofixed(f2)); }
inline bool operator<(const bofixed& f1, Q_ULONG f2) { return f1.isLess(bofixed(f2)); }
inline bool operator<(const bofixed& f1, float f2) { return f1.isLess(bofixed(f2)); }
inline bool operator<(const bofixed& f1, double f2) { return f1.isLess(bofixed(f2)); }
inline bool operator<(Q_INT32 f1, const bofixed& f2) { return bofixed(f1).isLess(f2); }
inline bool operator<(Q_UINT32 f1, const bofixed& f2) { return bofixed(f1).isLess(f2); }
inline bool operator<(Q_INT16 f1, const bofixed& f2) { return bofixed(f1).isLess(f2); }
inline bool operator<(Q_UINT16 f1, const bofixed& f2) { return bofixed(f1).isLess(f2); }
inline bool operator<(Q_INT8 f1, const bofixed& f2) { return bofixed(f1).isLess(f2); }
inline bool operator<(Q_UINT8 f1, const bofixed& f2) { return bofixed(f1).isLess(f2); }
inline bool operator<(Q_LONG f1, const bofixed& f2) { return bofixed(f1).isLess(f2); }
inline bool operator<(Q_ULONG f1, const bofixed& f2) { return bofixed(f1).isLess(f2); }
inline bool operator<(float f1, const bofixed& f2) { return bofixed(f1).isLess(f2); }
inline bool operator<(double f1, const bofixed& f2) { return bofixed(f1).isLess(f2); }
inline bool operator>(const bofixed& f1, const bofixed& f2) { return f1.isGreater(f2); }
inline bool operator>(const bofixed& f1, Q_INT32 f2) { return f1.isGreater(bofixed(f2)); }
inline bool operator>(const bofixed& f1, Q_UINT32 f2) { return f1.isGreater(bofixed(f2)); }
inline bool operator>(const bofixed& f1, Q_INT16 f2) { return f1.isGreater(bofixed(f2)); }
inline bool operator>(const bofixed& f1, Q_UINT16 f2) { return f1.isGreater(bofixed(f2)); }
inline bool operator>(const bofixed& f1, Q_INT8 f2) { return f1.isGreater(bofixed(f2)); }
inline bool operator>(const bofixed& f1, Q_UINT8 f2) { return f1.isGreater(bofixed(f2)); }
inline bool operator>(const bofixed& f1, Q_LONG f2) { return f1.isGreater(bofixed(f2)); }
inline bool operator>(const bofixed& f1, Q_ULONG f2) { return f1.isGreater(bofixed(f2)); }
inline bool operator>(const bofixed& f1, float f2) { return f1.isGreater(bofixed(f2)); }
inline bool operator>(const bofixed& f1, double f2) { return f1.isGreater(bofixed(f2)); }
inline bool operator>(Q_INT32 f1, const bofixed& f2) { return bofixed(f1).isGreater(f2); }
inline bool operator>(Q_UINT32 f1, const bofixed& f2) { return bofixed(f1).isGreater(f2); }
inline bool operator>(Q_INT16 f1, const bofixed& f2) { return bofixed(f1).isGreater(f2); }
inline bool operator>(Q_UINT16 f1, const bofixed& f2) { return bofixed(f1).isGreater(f2); }
inline bool operator>(Q_INT8 f1, const bofixed& f2) { return bofixed(f1).isGreater(f2); }
inline bool operator>(Q_UINT8 f1, const bofixed& f2) { return bofixed(f1).isGreater(f2); }
inline bool operator>(Q_LONG f1, const bofixed& f2) { return bofixed(f1).isGreater(f2); }
inline bool operator>(Q_ULONG f1, const bofixed& f2) { return bofixed(f1).isGreater(f2); }
inline bool operator>(float f1, const bofixed& f2) { return bofixed(f1).isGreater(f2); }
inline bool operator>(double f1, const bofixed& f2) { return bofixed(f1).isGreater(f2); }
#endif
|