IntDivExact
IntDivExact
Description
Generic exact-division convenience macro.
Parameters
| Name | Direction | Description |
|---|---|---|
result |
out | Destination for the quotient |
dividend |
in | Dividend |
divisor |
in | Divisor selected through generic dispatch |
Usage example (from documentation)
bool ok = IntDivExact("ient, &value, 5u);Returns
true when the division is exact.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Float.c:249:
u64 places = (u64)(-value->exponent);
Int factor = float_pow10(places);
bool ok = IntDivExact(&temp, &value->significand, &factor);
IntDeinit(&factor);- In
Int.c:993:
}
bool(IntDivExact)(Int *result, Int *dividend, Int *divisor) {
ValidateInt(result);
ValidateInt(dividend);- In
Int.c:1033:
bool MISRA_PRIV_IntDivExactU64(Int *result, Int *dividend, u64 divisor) {
Int divisor_value = MISRA_PRIV_IntFromU64(divisor);
bool ok = IntDivExact(result, dividend, &divisor_value);
IntDeinit(&divisor_value);- In
Int.c:1041:
bool MISRA_PRIV_IntDivExactI64(Int *result, Int *dividend, i64 divisor) {
Int divisor_value = MISRA_PRIV_IntFromI64(divisor);
bool ok = IntDivExact(result, dividend, &divisor_value);
IntDeinit(&divisor_value);- In
Int.Math.c:336:
bool test_int_div_exact(void) {
WriteFmt("Testing IntDivExact generic dispatch\n");
Int dividend = IntFromStr("12345678901234567890");- In
Int.Math.c:342:
Str text = StrInit();
bool result = IntDivExact(&result_value, ÷nd, 90u);
text = IntToStr(&result_value);
result = result && (strcmp(text.data, "137174210013717421") == 0);- In
Int.Math.c:353:
bool test_int_div_exact_failure_preserves_result(void) {
WriteFmt("Testing IntDivExact failure handling\n");
Int dividend = IntFrom(10);- In
Int.Math.c:359:
Int result_value = IntFrom(99);
bool result = !IntDivExact(&result_value, ÷nd, &divisor);
result = result && (IntToU64(&result_value) == 99);- In
Math.h:135:
/// TAGS: Int, Math, DivideExact
///
bool (IntDivExact)(Int *result, Int *dividend, Int *divisor);
///
/// Compute `dividend mod divisor`.
- In
Math.h:525:
(divisor), \
Int: MISRA_PRIV_IntDivExactValue, \
Int *: IntDivExact, \
const Int *: MISRA_PRIV_IntDivExactConst, \
unsigned char: MISRA_PRIV_IntDivExactU64, \
Last updated on