IntLCM
Description
Compute the least common multiple of two integers.
Parameters
| Name | Direction | Description |
|---|---|---|
result |
out | Destination for the LCM |
a |
in | First operand |
b |
in | Second operand |
Usage example (from documentation)
IntLCM(&lcm, &a, &b);Success
Returns true. *result holds lcm(a, b).
Failure
Returns false on allocator OOM while growing result. *result is left untouched.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:1964:
}
bool IntLCM(Int *result, const Int *a, const Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Math.c:507:
bool test_int_lcm(void) {
WriteFmt("Testing IntLCM\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:515:
Int result_value = IntInit(&alloc.base);
IntLCM(&result_value, &a, &b);
bool result = IntToU64(&result_value) == 42;- In
Math.c:1839:
// the int_replace void-call is stripped.
bool test_m16_lcm_zero_operand_replaces_result(void) {
WriteFmt("Testing IntLCM zero-operand zeroes result\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:1847:
Int result_value = IntFrom(99, &alloc.base);
bool result = IntLCM(&result_value, &a, &b);
result = result && IntIsZero(&result_value);
result = result && (IntCompare(&result_value, 0) == 0);- In
Math.c:4014:
Int r = IntFrom(7u, a);
bool ok = IntLCM(&r, &x, &y);
ok = ok && IntToU64(&r) == 42u;
Last updated on