FloatMul
Description
Generic multiplication convenience macro for Float.
Parameters
| Name | Direction | Description |
|---|---|---|
result |
out | Destination for the product |
a |
in | Left operand |
b |
in | Right operand selected through generic dispatch |
Usage example (from documentation)
FloatMul(&product, &value, 0.5f);Success
Returns true; *result holds a * b with the exponents summed and the significand normalized.
Failure
Returns false if an intermediate allocation (significand multiply / normalize) fails; *result is unchanged.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Float.Math.c:235:
bool test_float_mul_small_small(void) {
WriteFmt("Testing FloatMul with small floats\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Float.Math.c:244:
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);
text = FloatToStr(&result_value);- In
Float.Math.c:258:
bool test_float_mul_very_large_small(void) {
WriteFmt("Testing FloatMul with very large and small floats\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Float.Math.c:267:
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);
text = FloatToStr(&result_value);- In
Float.Math.c:281:
bool test_float_mul_generic(void) {
WriteFmt("Testing FloatMul generic dispatch\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Float.Math.c:291:
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "3") == 0;- In
Float.Math.c:296:
StrDeinit(&text);
FloatMul(&result_value, &a, &whole);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3") == 0);- In
Float.Math.c:301:
StrDeinit(&text);
FloatMul(&result_value, &a, 2u);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3") == 0);- In
Float.Math.c:306:
StrDeinit(&text);
FloatMul(&result_value, &a, -2);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "-3") == 0);- In
Float.Math.c:311:
StrDeinit(&text);
FloatMul(&result_value, &a, 0.5f);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "0.75") == 0);
Last updated on