Go to the source code of this file.
|  | 
| class | CFixed< T, max_t, total_bits, int_bits, fract_bits_, fract_pow2 > | 
|  | A simple fixed-point number class.  More... 
 | 
|  | 
| struct | std::numeric_limits< CFixed< T, max_t, total_bits, int_bits, fract_bits_, fract_pow2 > > | 
|  | std::numeric_limits specialisation, currently just providing min and max  More... 
 | 
|  | 
|  | 
| #define | USE_FIXED_OVERFLOW_CHECKS | 
|  | 
| #define | MUL_I64_I32_I32(a,  b)   	static_cast<i64>(a) * static_cast<i64>(b) | 
|  | 
| #define | SQUARE_U64_FIXED(a)   	static_cast<u64>(static_cast<i64>((a).GetInternalValue()) * static_cast<i64>((a).GetInternalValue())) | 
|  | 
| #define | CheckSignedSubtractionOverflow(type,  left,  right,  overflowWarning,  underflowWarning) | 
|  | 
| #define | CheckSignedAdditionOverflow(type,  left,  right,  overflowWarning,  underflowWarning) | 
|  | 
| #define | CheckCastOverflow(var,  targetType,  overflowWarning,  underflowWarning) | 
|  | 
| #define | CheckU32CastOverflow(var,  targetType,  overflowWarning) | 
|  | 
| #define | CheckUnsignedAdditionOverflow(result,  operand,  overflowWarning) | 
|  | 
| #define | CheckUnsignedSubtractionOverflow(result,  left,  overflowWarning) | 
|  | 
| #define | CheckNegationOverflow(var,  type,  overflowWarning) | 
|  | 
| #define | CheckMultiplicationOverflow(type,  left,  right,  overflowWarning,  underflowWarning) | 
|  | 
| #define | CheckDivisionOverflow(type,  left,  right,  overflowWarning)   	if(right == -1) { CheckNegationOverflow(left, type, overflowWarning) } | 
|  | 
◆ CheckCastOverflow
      
        
          | #define CheckCastOverflow | ( |  | var, | 
        
          |  |  |  | targetType, | 
        
          |  |  |  | overflowWarning, | 
        
          |  |  |  | underflowWarning | 
        
          |  | ) |  |  | 
      
 
Value:    if(var > std::numeric_limits<targetType>::max()) \
        debug_warn(overflowWarning); \
    else if(var < std::numeric_limits<targetType>::min()) \
        debug_warn(underflowWarning);
 
 
◆ CheckDivisionOverflow
      
        
          | #define CheckDivisionOverflow | ( |  | type, | 
        
          |  |  |  | left, | 
        
          |  |  |  | right, | 
        
          |  |  |  | overflowWarning | 
        
          |  | ) |  | if(right == -1) { CheckNegationOverflow(left, type, overflowWarning) } | 
      
 
 
◆ CheckMultiplicationOverflow
      
        
          | #define CheckMultiplicationOverflow | ( |  | type, | 
        
          |  |  |  | left, | 
        
          |  |  |  | right, | 
        
          |  |  |  | overflowWarning, | 
        
          |  |  |  | underflowWarning | 
        
          |  | ) |  |  | 
      
 
Value:
    CheckCastOverflow(res##left, type, overflowWarning, underflowWarning)
int64_t i64
Definition: types.h:35
 
 
 
◆ CheckNegationOverflow
      
        
          | #define CheckNegationOverflow | ( |  | var, | 
        
          |  |  |  | type, | 
        
          |  |  |  | overflowWarning | 
        
          |  | ) |  |  | 
      
 
Value:    if(value == std::numeric_limits<type>::min()) \
        debug_warn(overflowWarning);
 
 
◆ CheckSignedAdditionOverflow
      
        
          | #define CheckSignedAdditionOverflow | ( |  | type, | 
        
          |  |  |  | left, | 
        
          |  |  |  | right, | 
        
          |  |  |  | overflowWarning, | 
        
          |  |  |  | underflowWarning | 
        
          |  | ) |  |  | 
      
 
Value:    if(left > 0 && right > 0 && std::numeric_limits<type>::max() - left < right) \
        debug_warn(overflowWarning); \
    else if(left < 0 && right < 0 && std::numeric_limits<type>::min() - left > right) \
        debug_warn(underflowWarning);
 
 
◆ CheckSignedSubtractionOverflow
      
        
          | #define CheckSignedSubtractionOverflow | ( |  | type, | 
        
          |  |  |  | left, | 
        
          |  |  |  | right, | 
        
          |  |  |  | overflowWarning, | 
        
          |  |  |  | underflowWarning | 
        
          |  | ) |  |  | 
      
 
Value:    if(left > 0 && right < 0 && left > std::numeric_limits<type>::max() + right) \
        debug_warn(overflowWarning); \
    else if(left < 0 && right > 0 && left < std::numeric_limits<type>::min() + right) \
        debug_warn(underflowWarning);
 
 
◆ CheckU32CastOverflow
      
        
          | #define CheckU32CastOverflow | ( |  | var, | 
        
          |  |  |  | targetType, | 
        
          |  |  |  | overflowWarning | 
        
          |  | ) |  |  | 
      
 
Value:    if(var > (
u32)std::numeric_limits<targetType>::max()) \
 
        debug_warn(overflowWarning);
uint32_t u32
Definition: types.h:39
 
 
◆ CheckUnsignedAdditionOverflow
      
        
          | #define CheckUnsignedAdditionOverflow | ( |  | result, | 
        
          |  |  |  | operand, | 
        
          |  |  |  | overflowWarning | 
        
          |  | ) |  |  | 
      
 
Value:    if(result < operand) \
        debug_warn(overflowWarning);
 
 
◆ CheckUnsignedSubtractionOverflow
      
        
          | #define CheckUnsignedSubtractionOverflow | ( |  | result, | 
        
          |  |  |  | left, | 
        
          |  |  |  | overflowWarning | 
        
          |  | ) |  |  | 
      
 
Value:    if(result > left) \
        debug_warn(overflowWarning);
 
 
◆ MUL_I64_I32_I32
      
        
          | #define MUL_I64_I32_I32 | ( |  | a, | 
        
          |  |  |  | b | 
        
          |  | ) |  | static_cast<i64>(a) * static_cast<i64>(b) | 
      
 
 
◆ SQUARE_U64_FIXED
      
        
          | #define SQUARE_U64_FIXED | ( |  | a | ) | static_cast<u64>(static_cast<i64>((a).GetInternalValue()) * static_cast<i64>((a).GetInternalValue())) | 
      
 
 
◆ USE_FIXED_OVERFLOW_CHECKS
      
        
          | #define USE_FIXED_OVERFLOW_CHECKS | 
      
 
 
◆ CFixed_15_16
A fixed-point number class with 1-bit sign, 15-bit integral part, 16-bit fractional part. 
 
 
◆ fixed
Default fixed-point type used by the engine. 
 
 
◆ atan2_approx()
Inaccurate approximation of atan2 over fixed-point numbers. 
Maximum error is almost 0.08 radians (4.5 degrees). 
 
 
◆ round_away_from_zero() [1/2]
  
  | 
        
          | T round_away_from_zero | ( | double | value | ) |  |  | inline | 
 
 
◆ round_away_from_zero() [2/2]
  
  | 
        
          | T round_away_from_zero | ( | float | value | ) |  |  | inline | 
 
 
◆ sincos_approx()
Compute sin(a) and cos(a). 
Maximum error for -2pi < a < 2pi is almost 0.0005.