![]() |
Speeduino
|
Integer division returns the quotient. I.e. rounds to zero. This code will round the result to nearest integer. Rounding behavior is controlled by DIV_ROUND_BEHAVIOR. More...

Modules | |
| Rounding behavior | |
Macros | |
| #define | DIV_ROUND_CLOSEST(n, d, t) |
| Rounded integer division. | |
| #define | UDIV_ROUND_CLOSEST(n, d, t) ((t)((n) + DIV_ROUND_CORRECT(d, t))/(t)(d)) |
| Rounded unsigned integer division. | |
| #define | UDIV_ROUND_UP(n, d, t) ((t)((n) + (t)((d)+1U))/(t)(d)) |
| Rounding up unsigned integer division. | |
Functions | |
| template<uint16_t divisor> | |
| TESTABLE_STATIC_CONSTEXPR uint16_t | div_round_closest_u16 (uint16_t n) |
| Rounded unsigned integer division optimized for compile time constants. | |
Integer division returns the quotient. I.e. rounds to zero. This code will round the result to nearest integer. Rounding behavior is controlled by DIV_ROUND_BEHAVIOR.
Rounded integer division.
Integer division returns the quotient. I.e. rounds to zero. This macro will round the result to nearest integer. Rounding behavior is controlled by DIV_ROUND_BEHAVIOR
| n | The numerator (dividee) (an integer) |
| d | The denominator (divider) (an integer) |
| t | The type of the result. E.g. uint16_t |
Rounded unsigned integer division.
This is slightly faster than the signed version (DIV_ROUND_CLOSEST(n, d, t))
| n | The numerator (dividee) (an unsigned integer) |
| d | The denominator (divider) (an unsigned integer) |
| t | The type of the result. E.g. uint16_t |
Rounding up unsigned integer division.
| TESTABLE_STATIC_CONSTEXPR uint16_t div_round_closest_u16 | ( | uint16_t | n | ) |
Rounded unsigned integer division optimized for compile time constants.
| divisor | Divisor |
| n | Dividend |
