#include "lib/types.h"
#include "maths/Sqrt.h"
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 | FIXED_MUL_I64_I32_I32(a, b) ((i64)(a) * (i64)(b)) |
|
#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) } |
|
#define CheckCastOverflow |
( |
|
var, |
|
|
|
targetType, |
|
|
|
overflowWarning, |
|
|
|
underflowWarning |
|
) |
| |
Value:if(var > std::numeric_limits<targetType>::max())
\
else
if(var < std::numeric_limits<targetType>::min())
\
#define debug_warn(expr)
display the error dialog with the given text.
Definition at line 66 of file Fixed.h.
#define CheckDivisionOverflow |
( |
|
type, |
|
|
|
left, |
|
|
|
right, |
|
|
|
overflowWarning |
|
) |
| if(right == -1) { CheckNegationOverflow(left, type, overflowWarning) } |
#define CheckMultiplicationOverflow |
( |
|
type, |
|
|
|
left, |
|
|
|
right, |
|
|
|
overflowWarning, |
|
|
|
underflowWarning |
|
) |
| |
Value:
#define CheckCastOverflow(var, targetType, overflowWarning, underflowWarning)
Definition at line 88 of file Fixed.h.
#define CheckNegationOverflow |
( |
|
var, |
|
|
|
type, |
|
|
|
overflowWarning |
|
) |
| |
Value:if(value == std::numeric_limits<type>::min())
\
#define debug_warn(expr)
display the error dialog with the given text.
Definition at line 84 of file Fixed.h.
#define CheckSignedAdditionOverflow |
( |
|
type, |
|
|
|
left, |
|
|
|
right, |
|
|
|
overflowWarning, |
|
|
|
underflowWarning |
|
) |
| |
Value:if(left > 0 && right > 0 && std::numeric_limits<type>::max() - left < right)
\
else
if(left < 0 && right < 0 && std::numeric_limits<type>::min() - left > right)
\
#define debug_warn(expr)
display the error dialog with the given text.
Definition at line 60 of file Fixed.h.
#define CheckSignedSubtractionOverflow |
( |
|
type, |
|
|
|
left, |
|
|
|
right, |
|
|
|
overflowWarning, |
|
|
|
underflowWarning |
|
) |
| |
Value:if(left > 0 && right < 0 && left > std::numeric_limits<type>::max() + right)
\
else
if(left < 0 && right > 0 && left < std::numeric_limits<type>::min() + right)
\
#define debug_warn(expr)
display the error dialog with the given text.
Definition at line 54 of file Fixed.h.
#define CheckU32CastOverflow |
( |
|
var, |
|
|
|
targetType, |
|
|
|
overflowWarning |
|
) |
| |
Value:if(var > (
u32)std::numeric_limits<targetType>::max())
\
#define debug_warn(expr)
display the error dialog with the given text.
Definition at line 72 of file Fixed.h.
#define CheckUnsignedAdditionOverflow |
( |
|
result, |
|
|
|
operand, |
|
|
|
overflowWarning |
|
) |
| |
Value:
#define debug_warn(expr)
display the error dialog with the given text.
Definition at line 76 of file Fixed.h.
#define CheckUnsignedSubtractionOverflow |
( |
|
result, |
|
|
|
left, |
|
|
|
overflowWarning |
|
) |
| |
Value:
#define debug_warn(expr)
display the error dialog with the given text.
Definition at line 80 of file Fixed.h.
#define FIXED_MUL_I64_I32_I32 |
( |
|
a, |
|
|
|
b |
|
) |
| ((i64)(a) * (i64)(b)) |
#define USE_FIXED_OVERFLOW_CHECKS |
typedef CFixed<i32, (i32)0x7fffffff, 32, 15, 16, 65536> CFixed_15_16 |
A fixed-point number class with 1-bit sign, 15-bit integral part, 16-bit fractional part.
Definition at line 334 of file Fixed.h.
Default fixed-point type used by the engine.
Definition at line 339 of file Fixed.h.
Inaccurate approximation of atan2 over fixed-point numbers.
Maximum error is almost 0.08 radians (4.5 degrees).
Definition at line 147 of file Fixed.cpp.
template<typename T >
T round_away_from_zero |
( |
float |
value | ) |
|
|
inline |
template<typename T >
T round_away_from_zero |
( |
double |
value | ) |
|
|
inline |
Compute sin(a) and cos(a).
Maximum error for -2pi < a < 2pi is almost 0.0005.
Definition at line 187 of file Fixed.cpp.