Go to the source code of this file.
|
#define | fr_add(_out, _a, _b) !__builtin_add_overflow(_a, _b, _out) |
| Adds two integers. More...
|
|
#define | fr_multiply(_out, _a, _b) !__builtin_mul_overflow(_a, _b, _out) |
| Multiplies two integers together. More...
|
|
#define | fr_sub(_out, _a, _b) !__builtin_sub_overflow(_a, _b, _out) |
| Subtracts two integers. More...
|
|
#define | ROUND_UP(_num, _mul) (((((_num) + ((_mul) - 1))) / (_mul)) * (_mul)) |
| Round up - Works in all cases, but is slower. More...
|
|
#define | ROUND_UP_DIV(_x, _y) (1 + (((_x) - 1) / (_y))) |
| Get the ceiling value of integer division. More...
|
|
#define | ROUND_UP_POW2(_num, _mul) (((_num) + ((_mul) - 1)) & ~((_mul) - 1)) |
| Round up - Only works if _mul is a power of 2 but avoids division. More...
|
|
◆ fr_add
#define fr_add |
( |
|
_out, |
|
|
|
_a, |
|
|
|
_b |
|
) |
| !__builtin_add_overflow(_a, _b, _out) |
Adds two integers.
- Parameters
-
[in] | _out | Where to store the result. |
[in] | _a | first argument to add. |
[in] | _b | second argument to add. |
- Returns
- false on overflow.
- true if there was no overflow.
Definition at line 129 of file math.h.
◆ fr_multiply
#define fr_multiply |
( |
|
_out, |
|
|
|
_a, |
|
|
|
_b |
|
) |
| !__builtin_mul_overflow(_a, _b, _out) |
Multiplies two integers together.
- Parameters
-
[in] | _out | Where to store the result. |
[in] | _a | first argument to multiply. |
[in] | _b | second argument to multiply. |
- Returns
- false on overflow.
- true if there was no overflow.
Definition at line 118 of file math.h.
◆ fr_sub
#define fr_sub |
( |
|
_out, |
|
|
|
_a, |
|
|
|
_b |
|
) |
| !__builtin_sub_overflow(_a, _b, _out) |
Subtracts two integers.
- Parameters
-
[in] | _out | Where to store the result. |
[in] | _a | first argument to subtract. |
[in] | _b | second argument to subtract. |
- Returns
- false on overflow.
- true if there was no overflow.
Definition at line 140 of file math.h.
◆ ROUND_UP
#define ROUND_UP |
( |
|
_num, |
|
|
|
_mul |
|
) |
| (((((_num) + ((_mul) - 1))) / (_mul)) * (_mul)) |
Round up - Works in all cases, but is slower.
Definition at line 148 of file math.h.
◆ ROUND_UP_DIV
#define ROUND_UP_DIV |
( |
|
_x, |
|
|
|
_y |
|
) |
| (1 + (((_x) - 1) / (_y))) |
Get the ceiling value of integer division.
Definition at line 153 of file math.h.
◆ ROUND_UP_POW2
#define ROUND_UP_POW2 |
( |
|
_num, |
|
|
|
_mul |
|
) |
| (((_num) + ((_mul) - 1)) & ~((_mul) - 1)) |
Round up - Only works if _mul is a power of 2 but avoids division.
Definition at line 144 of file math.h.
◆ fr_high_bit_pos()
static uint8_t fr_high_bit_pos |
( |
uint64_t |
num | ) |
|
|
inlinestatic |
Find the highest order high bit in an unsigned 64 bit integer.
- Returns
- 0-64 indicating the position of the highest bit, with 0 indicating no high bits, 1 indicating the 1st bit and 64 indicating the last bit.
Definition at line 36 of file math.h.
◆ fr_log10()
static uint8_t fr_log10 |
( |
uint64_t |
num | ) |
|
|
inlinestatic |
Efficient calculation of log10 of a unsigned 64bit integer.
- Parameters
-
[in] | num | to calculate log10 of. |
- Returns
- log10 of the integer
Definition at line 78 of file math.h.
◆ fr_low_bit_pos()
static uint8_t fr_low_bit_pos |
( |
uint64_t |
num | ) |
|
|
inlinestatic |
Find the lowest order high bit in an unsigned 64 bit integer.
- Returns
- 0-64 indicating the position of the lowest bit, with 0 indicating no high bits, 1 indicating the 1st bit and 64 indicating the last bit.
Definition at line 55 of file math.h.