IntAdd
IntAdd
Description
Generic addition convenience macro. Dispatches on the type of b to the matching IntAdd* overload.
Parameters
| Name | Direction | Description |
|---|---|---|
result |
out | Destination for the sum |
a |
in | Left operand |
b |
in | Right operand (Int, pointer, u64, or i64 compatible type) |
Usage example (from documentation)
IntAdd(&sum, &value, 10u);Usage example (Cross-references)
Usage examples (Cross-references)
- In
Float.c:476:
if (lhs.negative == rhs.negative) {
IntAdd(&temp.significand, &lhs.significand, &rhs.significand);
temp.negative = lhs.negative;
} else {- In
Int.c:113:
if (a->negative == b->negative) {
IntAdd(&temp.magnitude, &a->magnitude, &b->magnitude);
temp.negative = a->negative;
} else {- In
Int.c:185:
Int result = IntInit();
IntAdd(&result, &lhs, &rhs);
IntDeinit(&lhs);- In
Int.c:696:
}
void(IntAdd)(Int *result, Int *a, Int *b) {
ValidateInt(result);
ValidateInt(a);- In
Int.c:752:
if (!MISRA_PRIV_IntSubU64(result, value, magnitude)) {
LOG_FATAL("IntAdd would produce a negative result");
}
}- In
Int.c:840:
int_normalize(&partial);
IntShiftLeft(&partial, i);
IntAdd(&next, &acc, &partial);
IntDeinit(&acc);- In
Int.c:1214:
int cmp = 0;
IntAdd(&sum, &low, &high);
IntShiftRight(&sum, 1);
mid = sum;- In
Int.c:1226:
IntDeinit(&best);
best = IntClone(&mid);
IntAdd(&next, &mid, &one);
IntDeinit(&low);
low = next;- In
Int.c:1383:
IntMod(&ar, a, modulus);
IntMod(&br, b, modulus);
IntAdd(&sum, &ar, &br);
IntMod(result, &sum, modulus);- In
Int.Math.c:90:
bool test_int_add(void) {
WriteFmt("Testing IntAdd\n");
Int a = IntFrom(255);- In
Int.Math.c:97:
Str text = StrInit();
IntAdd(&result_value, &a, &b);
text = IntToBinary(&result_value);- In
Int.Math.c:111:
bool test_int_add_generic(void) {
WriteFmt("Testing IntAdd generic dispatch\n");
Int base = IntFrom(40);- In
Int.Math.c:119:
Str text = StrInit();
IntAdd(&result_value, &base, rhs);
bool result = IntToU64(&result_value) == 42;- In
Int.Math.c:122:
bool result = IntToU64(&result_value) == 42;
IntAdd(&result_value, &base, 2);
result = result && (IntToU64(&result_value) == 42);- In
Int.Math.c:125:
result = result && (IntToU64(&result_value) == 42);
IntAdd(&result_value, &base, -2);
result = result && (IntToU64(&result_value) == 38);- In
Int.Math.c:128:
result = result && (IntToU64(&result_value) == 38);
IntAdd(&result_value, &huge, 10);
text = IntToStr(&result_value);
result = result && (strcmp(text.data, "123456789012345678901234567900") == 0);- In
Int.Math.c:823:
bool test_int_add_null_result(void) {
WriteFmt("Testing IntAdd NULL result handling\n");
Int a = IntFrom(1);- In
Int.Math.c:828:
Int b = IntFrom(2);
IntAdd(NULL, &a, &b);
return false;
}- In
Math.h:52:
/// TAGS: Int, Math, Add
///
void (IntAdd)(Int *result, Int *a, Int *b);
///
/// Subtract one integer from another.
- In
Math.h:435:
(rhs), \
Int: MISRA_PRIV_IntAddValue, \
Int *: IntAdd, \
const Int *: MISRA_PRIV_IntAddConst, \
unsigned char: MISRA_PRIV_IntAddU64, \
Last updated on