IntModDiv
Description
Compute modular division a / b (mod modulus).
Parameters
| Name | Direction | Description |
|---|---|---|
result |
out | Destination for the reduced quotient |
a |
in | Numerator |
b |
in | Denominator |
modulus |
in | Modulus |
Usage example (from documentation)
bool ok = IntModDiv(&result, &a, &b, &modulus);Success
Returns true when a modular inverse for b exists.
Failure
Returns false otherwise.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:2132:
}
bool IntModDiv(Int *result, const Int *a, const Int *b, const Int *modulus) {
ValidateInt(result);
ValidateInt(a);- In
Int.Math.c:739:
bool test_int_mod_div(void) {
WriteFmt("Testing IntModDiv\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:749:
Int check = IntInit(&alloc.base);
bool result = IntModDiv(&result_value, &a, &b, &m);
result = result && (IntToU64(&result_value) == 12);- In
Int.Math.c:929:
bool test_int_mod_div_no_solution(void) {
WriteFmt("Testing IntModDiv no-solution case\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:938:
Int result_value = IntFrom(99, &alloc.base);
bool result = !IntModDiv(&result_value, &a, &b, &m);
result = result && (IntCompare(&result_value, 99) == 0);- In
Int.Math.c:1050:
bool test_int_mod_div_zero_modulus(void) {
WriteFmt("Testing IntModDiv zero modulus handling\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:1059:
Int result_value = IntFrom(99, &alloc.base);
bool result = !IntModDiv(&result_value, &a, &b, &m);
result = result && (IntCompare(&result_value, 99) == 0);
Last updated on