FloatAdd
Description
Generic addition convenience macro for Float.
Parameters
| Name | Direction | Description |
|---|---|---|
result |
out | Destination for the sum |
a |
in | Left operand |
b |
in | Right operand selected through generic dispatch |
Usage example (from documentation)
FloatAdd(&sum, &value, 1.25);Success
Returns true; *result holds a + b with shared exponent and normalized significand.
Failure
Returns false if an intermediate allocation (clone / rescale / add) fails; *result is unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Float.Math.c:50:
bool test_float_add_small_small(void) {
WriteFmt("Testing FloatAdd with small floats\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Float.Math.c:59:
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);
text = FloatToStr(&result_value);- In
Float.Math.c:73:
bool test_float_add_very_large_large(void) {
WriteFmt("Testing FloatAdd with very large floats\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Float.Math.c:82:
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);
text = FloatToStr(&result_value);- In
Float.Math.c:96:
bool test_float_add_generic(void) {
WriteFmt("Testing FloatAdd generic dispatch\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Float.Math.c:106:
Str text = StrInit(&alloc.base);
FloatAdd(&result_value, &a, &b);
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "2") == 0;- In
Float.Math.c:111:
StrDeinit(&text);
FloatAdd(&result_value, &a, &whole);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3.25") == 0);- In
Float.Math.c:116:
StrDeinit(&text);
FloatAdd(&result_value, &a, 2u);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3.25") == 0);- In
Float.Math.c:121:
StrDeinit(&text);
FloatAdd(&result_value, &a, -1);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "0.25") == 0);- In
Float.Math.c:126:
StrDeinit(&text);
FloatAdd(&result_value, &a, 0.75f);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "2") == 0);- In
Float.Math.c:131:
StrDeinit(&text);
FloatAdd(&result_value, &a, 0.75);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "2") == 0);
Last updated on