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. | |
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 |