FloatSub
Description
Generic subtraction convenience macro for Float.
Parameters
| Name | Direction | Description |
|---|---|---|
result |
out | Destination for the difference |
a |
in | Left operand |
b |
in | Right operand selected through generic dispatch |
Usage example (from documentation)
FloatSub(&diff, &value, 2u);Success
Returns true; *result holds a - b with shared exponent and normalized significand.
Failure
Returns false if an intermediate allocation (clone / rescale / subtract) fails; *result is unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Math.c:191:
bool test_float_sub_small_small(void) {
WriteFmt("Testing FloatSub with small floats\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:200:
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);
text = FloatToStr(&result_value);- In
Math.c:214:
bool test_float_sub_very_large_large(void) {
WriteFmt("Testing FloatSub with very large floats\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:223:
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);
text = FloatToStr(&result_value);- In
Math.c:237:
bool test_float_sub_generic(void) {
WriteFmt("Testing FloatSub generic dispatch\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:247:
Str text = StrInit(&alloc.base);
FloatSub(&result_value, &a, &b);
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "5") == 0;- In
Math.c:252:
StrDeinit(&text);
FloatSub(&result_value, &a, &whole);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3.5") == 0);- In
Math.c:257:
StrDeinit(&text);
FloatSub(&result_value, &a, 2u);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3.5") == 0);- In
Math.c:262:
StrDeinit(&text);
FloatSub(&result_value, &a, -2);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "7.5") == 0);- In
Math.c:267:
StrDeinit(&text);
FloatSub(&result_value, &a, 0.5f);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "5") == 0);- In
Math.c:1218:
Float r = FloatInit(&dbg.base);
bool ok = FloatSub(&r, &a, &b);
FloatDeinit(&a);- In
Math.c:1235:
Int b = IntFrom(2, &dbg.base);
bool ok = FloatSub(&r, &a, &b);
FloatDeinit(&a);- In
Math.c:1251:
Float r = FloatInit(&dbg.base);
bool ok = FloatSub(&r, &a, 2u);
FloatDeinit(&a);- In
Math.c:1266:
Float r = FloatInit(&dbg.base);
bool ok = FloatSub(&r, &a, -2);
FloatDeinit(&a);- In
Math.c:1281:
Float r = FloatInit(&dbg.base);
bool ok = FloatSub(&r, &a, 0.5f);
FloatDeinit(&a);- In
Math.c:1296:
Float r = FloatInit(&dbg.base);
bool ok = FloatSub(&r, &a, 0.25);
FloatDeinit(&a);
Last updated on