src/fixedt.h
author celestar
Wed, 07 Mar 2007 14:36:57 +0000
branchgamebalance
changeset 9877 29bb0e8924b7
parent 9876 f8302fbd236d
child 9878 98be05df31ef
permissions -rw-r--r--
(svn r9052) [gamebalance] -Add: Unary minus operator for FixedT
9876
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
     1
/* $Id */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
     2
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
     3
/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
     4
 * @file
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
     5
 * Implements a Fixed-point data type.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
     6
 * This files defines a new data type
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
     7
 * "FixedT<Tstorage, Tdec_bits>", which can be used to compute fractional
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
     8
 * numbers without having to worry about network stability (because
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
     9
 * there is no real rounding taking place.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    10
 * Use "Fixed" for the defaults values (48 bits integral part, 16 bits
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    11
 * fractional part) or "FixedT<typename, int>" for flexible sizes. "int"
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    12
 * number of bits are taken from a variable of "typename" for the fractional
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    13
 * representation, the rest stays available for the integral part.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    14
 * @warning More than 16 bits fractional should not be used when working
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    15
 * with large integers.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    16
 * @warning More than 31 fractional bits are not supported, and will
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    17
 * trigger a compiler warning with appropriate settings.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    18
 * @warning There are no warnings for buffer overflows. Those are very likely
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    19
 * to happen with divisions, as those first shift the numerator by the number
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    20
 * of fractional bits. Use multiplication with the reciprocal whereever
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    21
 * it is possible.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    22
 * @warning Please use signed variables for storage at the moment ONLY
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    23
 *
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    24
 * Variables can be initialized:
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    25
 * 	- with integers: "FixedT<int, 9> a = -5"
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    26
 * 	- with fractionals: "FixedT<int64, 11> b(7, 2);" where the first number is
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    27
 * the numerator and the second is the denominator.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    28
 * 	- not at all: "Fixed c;", which will automatically set c to zero.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    29
 *
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    30
 * @example fixed_ex.cpp How to initialize Fixed-point data types
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    31
 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    32
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    33
/* Included to overload the stream operator << */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    34
#include <iostream>
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    35
/* Needed for some ottd-specific data types */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    36
#include "stdafx.h"
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    37
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    38
/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    39
 * Base Class for storing fixed-point data types.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    40
 * Fixed-point data types are stored in a single integer-type variable
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    41
 * (Tstorage) of which a certain number of bits (Tdec_bits) is used to
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    42
 * represent the fractional part of the number.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    43
 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    44
template <typename Tstorage, int Tdec_bits>
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    45
class FixedRawT {
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    46
public:
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    47
	/** The number of bits that represent the fractional */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    48
	static const int dec_bits = Tdec_bits;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    49
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    50
	/** The storage of the number itself */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    51
	Tstorage m_data;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    52
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    53
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    54
	 * Basic constructor for integer arguments.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    55
	 * @param value The raw value to which we want to initialize
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    56
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    57
	template <typename T>
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    58
	FixedRawT(T value) : m_data(value) {}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    59
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    60
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    61
	 * Make sure that a Fixed variable is always inizialized to zero by default.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    62
	 * We need this ctor so that we can declare variable without
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    63
	 * the need to initialize it explicitly
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    64
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    65
	FixedRawT() : m_data (0) {}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    66
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    67
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    68
	 * Returns the biggest integral number we can represent
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    69
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    70
	int64 FIXED_MAX() const { return m_maximum; }
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    71
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    72
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    73
	 * Returns the biggest integral number we can represent
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    74
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    75
	int64 FIXED_MIN() const { return m_minimum; }
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    76
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    77
private:
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    78
	/** The largest number we can hold */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    79
	static const int64 m_maximum = +(1ULL << ((sizeof(Tstorage) * 8) - Tdec_bits - 1)) - 1;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    80
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    81
	/** The smallest number we can hold */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    82
	static const int64 m_minimum = -(1ULL << ((sizeof(Tstorage) * 8) - Tdec_bits - 1)) - 0;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    83
};
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    84
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    85
/* forward-declare some structs */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    86
template <typename Tstorage, int Tdec_bits> class FixedT;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    87
template <typename T> struct FixedHelperT;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    88
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    89
/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    90
 * Specialization of FixedHelperT. Used to decimal-align two variables of Fixed type.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    91
 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    92
template <typename Tstorage, int Tdec_bits> struct FixedHelperT<FixedRawT<Tstorage, Tdec_bits> >
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    93
{
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    94
	/** The number of bits used for the fraction */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    95
	static const int dec_bits = Tdec_bits;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    96
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    97
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    98
	 * Gives the raw data of a FixedRaw
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
    99
	 * @param t The number to return
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   100
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   101
	static int64 Raw(const FixedRawT<Tstorage, Tdec_bits>& t) {return (int64)t.m_data;}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   102
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   103
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   104
	 * Returns the data from FixedRawT aligned so that it is aligned to a given number
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   105
	 * @param t    The number to be aligned
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   106
	 * @param bits The number of bits in the fractional part to be aligned to
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   107
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   108
	static int64 Raw(const FixedRawT<Tstorage, Tdec_bits>& t, int bits)
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   109
	{
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   110
		return (((int64)t.m_data) << (bits > Tdec_bits ? bits - Tdec_bits : 0)) >> (bits < Tdec_bits ? Tdec_bits - bits : 0);
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   111
	}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   112
};
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   113
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   114
/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   115
 * Specialization of FixedHelperT. Used to decimal-align two variables of Fixed type.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   116
 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   117
template <typename Tstorage, int Tdec_bits> struct FixedHelperT<FixedT<Tstorage, Tdec_bits> > : public FixedHelperT<FixedRawT<Tstorage, Tdec_bits> > {};
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   118
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   119
/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   120
 * General implementation of FixedHelperT. This tempate makes sure that
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   121
 * some number supplied is properly aligned at the decimal
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   122
 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   123
template <typename T> struct FixedHelperT
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   124
{
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   125
	/** This version of FixedHelperT is only used for full integers, so assume the number of dec_bits to be zero */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   126
	static const int dec_bits = 0;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   127
	/** Converts a full integer to one that has a given number of fractional bits, assumes
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   128
	 * the number of fractional bits to be zero.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   129
	 * @param t the number to be converted
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   130
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   131
	static int64 Raw(const T& t) {return (int64)t;}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   132
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   133
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   134
	 * Converts a full integer to one that has a given number of fractional bits
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   135
	 * @param bits the number of bits for the fraction
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   136
	 * @param t    the number to be converted
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   137
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   138
	static int64 Raw(const T& t, int bits) {return ((int64)t) << bits;}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   139
};
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   140
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   141
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   142
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   143
/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   144
 * A class that defines a fixed-point data type, which a variable length and precision.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   145
 * The data type that is defined is a fixed-point variable that has and number of Tdec_bits
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   146
 * bits to represent the fractional part, the remaining bits of Tstorage are then used for
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   147
 * the integer part of the number. This means, we always need to make a trade-off between
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   148
 * the precision we want (higher number in Tdec_bits) and the range (smaller number of
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   149
 * Tdec_bits). This class here only defines the constructors and the operators, everything
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   150
 * else is happning in helper classes.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   151
 * @note for usage of fprintf and similar, explicit casts are needed (double or int64).
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   152
 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   153
template <typename Tstorage, int Tdec_bits> class FixedT : public FixedRawT<Tstorage, Tdec_bits> {
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   154
/* private block up here, because we need the typedef later on */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   155
private:
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   156
	/** We shortcut the underlying data type to "Raw", to save typing */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   157
	typedef FixedRawT<Tstorage, Tdec_bits> Raw;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   158
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   159
public:
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   160
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   161
	 * Ctor for assignment with other, non floating, variable types
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   162
	 * @param value The Value we should assign to the Fixed
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   163
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   164
	template <typename T> FixedT(T value) : Raw(FixedHelperT<T>::Raw(value, Tdec_bits)) {}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   165
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   166
	/** As a constructor without initializing, just use the one that Raw uses. Sets a variable to zero */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   167
	FixedT() : Raw() {}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   168
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   169
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   170
	 * Ctor for use with a fraction, useful for initing a variable to a non-integer number at declaration.
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   171
	 * @param numerator   The Nominator of the fraction
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   172
	 * @param denominator The Denominator of the fraction
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   173
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   174
	FixedT(int numerator, int denominator) {Raw::m_data = ((int64)numerator << Raw::dec_bits) / (int64)denominator;}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   175
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   176
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   177
	 * Equality operator
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   178
	 * @param comparator The non-floating point variable we want to compare against
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   179
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   180
	template <typename T>
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   181
	bool operator ==(const T &comparator) const { return Raw::m_data == (Tstorage)FixedHelperT<T>::Raw(comparator, Tdec_bits); }
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   182
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   183
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   184
	 * Inequality operator
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   185
	 * @param comparator The non-floating point variable we want to compare against
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   186
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   187
	template <typename T>
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   188
	bool operator !=(const T &comparator) const { return Raw::m_data != (Tstorage)FixedHelperT<T>::Raw(comparator, Tdec_bits); }
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   189
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   190
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   191
	 * Greater or equal operator
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   192
	 * @param comparator The non-floating point variable we want to compare against
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   193
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   194
	template <typename T>
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   195
	bool operator >=(const T &comparator) const { return Raw::m_data >= (Tstorage)FixedHelperT<T>::Raw(comparator, Tdec_bits); }
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   196
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   197
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   198
	 * Less or equal operator
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   199
	 * @param comparator The non-floating point variable we want to compare against
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   200
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   201
	template <typename T>
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   202
	bool operator <=(const T &comparator) const { return Raw::m_data <= (Tstorage)FixedHelperT<T>::Raw(comparator, Tdec_bits); }
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   203
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   204
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   205
	 * Greater than operator
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   206
	 * @param comparator The non-floating point variable we want to compare against
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   207
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   208
	template <typename T>
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   209
	bool operator >(const T &comparator) const { return Raw::m_data > (Tstorage)FixedHelperT<T>::Raw(comparator, Tdec_bits); }
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   210
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   211
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   212
	 * Less than operator
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   213
	 * @param comparator The non-floating point variable we want to compare against
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   214
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   215
	template <typename T>
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   216
	bool operator <(const T &comparator) const { return Raw::m_data < (Tstorage)FixedHelperT<T>::Raw(comparator, Tdec_bits); }
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   217
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   218
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   219
	 * Addition for Fixed-point data types
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   220
	 * @param value The non-floating point number to add
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   221
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   222
	template <typename T> FixedT operator +(const T &value) const
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   223
	{
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   224
		return Raw(Raw::m_data + (Tstorage)FixedHelperT<T>::Raw(value, Tdec_bits));
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   225
	}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   226
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   227
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   228
	 * Subtraction for Fixed-point data types
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   229
	 * @param value The non-floating point number to subtract
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   230
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   231
	template <typename T> FixedT operator -(const T &value) const
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   232
	{
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   233
		return Raw(Raw::m_data - (Tstorage)FixedHelperT<T>::Raw(value, Tdec_bits));
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   234
	}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   235
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   236
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   237
	 * A simple multiplication for non-floating data types
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   238
	 * @param value The non floating-point factor
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   239
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   240
	template <typename T> FixedT operator *(const T &value) const
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   241
	{
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   242
		return Raw( (((int64)Raw::m_data) * FixedHelperT<T>::Raw(value)) >> FixedHelperT<T>::dec_bits);
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   243
	}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   244
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   245
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   246
	 * A simple division for non-floating data types
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   247
	 * @param value The non floating-point divisor
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   248
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   249
	template <typename T> FixedT operator /(const T &value) const
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   250
	{
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   251
		return Raw( (((int64)Raw::m_data) << FixedHelperT<T>::dec_bits) / FixedHelperT<T>::Raw(value));
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   252
	}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   253
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   254
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   255
	 * Addition-assignment for Fixed-point data types
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   256
	 * @param value The non-floating point number to add
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   257
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   258
	template <typename T> FixedT& operator +=(const T &value)
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   259
	{
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   260
		Raw::m_data = Raw::m_data + (Tstorage)FixedHelperT<T>::Raw(value, Tdec_bits);
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   261
		return *this;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   262
	}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   263
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   264
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   265
	 * Subtract-assignment for Fixed-point data types
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   266
	 * @param value The non-floating point number to subtract
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   267
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   268
	template <typename T> FixedT& operator -=(const T &value)
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   269
	{
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   270
		Raw::m_data = Raw::m_data - (Tstorage)FixedHelperT<T>::Raw(value, Tdec_bits);
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   271
		return *this;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   272
	}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   273
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   274
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   275
	 * Multiply-assignment for Fixed-point data types
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   276
	 * @param value The non-floating point number to multiply
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   277
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   278
	template <typename T> FixedT& operator *=(const T &value)
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   279
	{
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   280
		Raw::m_data = (Raw::m_data * (Tstorage)FixedHelperT<T>::Raw(value)) >> FixedHelperT<T>::dec_bits;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   281
		return *this;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   282
	}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   283
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   284
	/**
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   285
	 * Divide-assignment for Fixed-point data types
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   286
	 * @param value The non-floating point number to use as divisor
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   287
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   288
	template <typename T> FixedT& operator /=(const T &value)
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   289
	{
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   290
		Raw::m_data = (Raw::m_data << FixedHelperT<T>::dec_bits) / (Tstorage)FixedHelperT<T>::Raw(value);
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   291
		return *this;
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   292
	}
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   293
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   294
	/**
9877
29bb0e8924b7 (svn r9052) [gamebalance] -Add: Unary minus operator for FixedT
celestar
parents: 9876
diff changeset
   295
	 * Unary minus operator
29bb0e8924b7 (svn r9052) [gamebalance] -Add: Unary minus operator for FixedT
celestar
parents: 9876
diff changeset
   296
	 */
29bb0e8924b7 (svn r9052) [gamebalance] -Add: Unary minus operator for FixedT
celestar
parents: 9876
diff changeset
   297
	FixedT operator -() const { return Raw(-Raw::m_data); }
29bb0e8924b7 (svn r9052) [gamebalance] -Add: Unary minus operator for FixedT
celestar
parents: 9876
diff changeset
   298
29bb0e8924b7 (svn r9052) [gamebalance] -Add: Unary minus operator for FixedT
celestar
parents: 9876
diff changeset
   299
	/**
9876
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   300
	 * Stream operator, used for floating point output
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   301
	 * @param os    The stream we are going to write to
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   302
	 * @param value The Fixed-point variable we want to write in the stream
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   303
	 */
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   304
	friend std::ostream& operator << (std::ostream &os, const FixedT &value) { os << (double)value.m_data / (1ULL << Raw::dec_bits); return os; }
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   305
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   306
};
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   307
f8302fbd236d (svn r9026) [gamebalance] -Add: Added a new data type that allows fixed-point computations, as to enable computing non-integral numbers without worrying about the FPU rounding differences and, thus, desyncs. It is fully doxygenned, read the usage there. Thanks a bunch to KUDr for helping me with templates
celestar
parents:
diff changeset
   308