IntDiv
Description
Generic 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)
IntDiv("ient, &value, 10u);Success
Returns true; *result holds the floor quotient of dividend / divisor.
Failure
Returns false when divisor is zero (logged) or when an intermediate allocation fails; *result is unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.Math.c:361:
bool test_int_div(void) {
WriteFmt("Testing IntDiv generic dispatch\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:368:
Int result_value = IntInit(&alloc.base);
IntDiv(&result_value, ÷nd, 10u);
bool result = IntToU64(&result_value) == 12;- In
Int.Math.c:1016:
bool test_int_div_scalar_zero_divisor(void) {
WriteFmt("Testing IntDiv scalar zero-divisor handling\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:1023:
Int quotient = IntFrom(99, &alloc.base);
IntDiv("ient, ÷nd, 0u);
bool result = IntCompare("ient, 99) == 0;
Last updated on