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);Success
Returns true when the division is exact.
Failure
Returns false otherwise.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.Math.c:379:
bool test_int_div_exact(void) {
WriteFmt("Testing IntDivExact generic dispatch\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:387:
Str text = StrInit(&alloc.base);
bool result = IntDivExact(&result_value, ÷nd, 90u);
text = IntToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "137174210013717421") == 0);- In
Int.Math.c:399:
bool test_int_div_exact_failure_preserves_result(void) {
WriteFmt("Testing IntDivExact failure handling\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:407:
Int result_value = IntFrom(99, &alloc.base);
bool result = !IntDivExact(&result_value, ÷nd, &divisor);
result = result && (IntToU64(&result_value) == 99);
Last updated on