Math functions like overflow aware addition.
More...
|
#define | VTM_MIN(a, b) ((a) < (b) ? (a) : (b)) |
|
#define | VTM_MAX(a, b) ((a) > (b) ? (a) : (b)) |
|
#define VTM_MIN |
( |
|
a, |
|
|
|
b |
|
) |
| ((a) < (b) ? (a) : (b)) |
Evaluates to the smaller argument
#define VTM_MAX |
( |
|
a, |
|
|
|
b |
|
) |
| ((a) > (b) ? (a) : (b)) |
Evaluates to the greater argument
VTM_API int vtm_math_size_add |
( |
size_t |
a, |
|
|
size_t |
b, |
|
|
size_t * |
r |
|
) |
| |
Overflow aware addition of two size_t values.
- Parameters
-
| a | first value |
| b | second value |
[out] | r | the result of the addion |
- Returns
- VTM_OK if the addition has not resulted in an overflow
-
VTM_E_OVERFLOW if the addition would cause an overflow
VTM_API int vtm_math_size_mul |
( |
size_t |
a, |
|
|
size_t |
b, |
|
|
size_t * |
r |
|
) |
| |
Overflow aware multiplication of two size_t values.
- Parameters
-
| a | the multiplicand |
| b | the multiplier |
[out] | r | the result |
- Returns
- VTM_OK if the multiplication has not resulted in an overflow
-
VTM_E_OVERFLOW if the multiplication would cause an overflow
VTM_API bool vtm_math_float_cmp |
( |
float |
a, |
|
|
float |
b, |
|
|
float |
epsilon |
|
) |
| |
Compares two float values for (relative) equality.
- Parameters
-
a | the first input float |
b | the second input float |
epsilon | the precision threshold |
VTM_API bool vtm_math_double_cmp |
( |
double |
a, |
|
|
double |
b, |
|
|
double |
epsilon |
|
) |
| |
Compares two double values for (relative) equality.
- Parameters
-
a | the first input double |
b | the second input double |
epsilon | the precision threshold |