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
Type.c:115:
Float r = FloatInit(&alloc.base);
bool ok = FloatMul(&r, &zero, &big);
ok = ok && FloatIsZero(&r);
ok = ok && (FloatExponent(&r) == 0);- In
Math.c:281:
bool test_float_mul_small_small(void) {
WriteFmt("Testing FloatMul with small floats\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:290:
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);
text = FloatToStr(&result_value);- In
Math.c:304:
bool test_float_mul_very_large_small(void) {
WriteFmt("Testing FloatMul with very large and small floats\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:313:
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);
text = FloatToStr(&result_value);- In
Math.c:327:
bool test_float_mul_generic(void) {
WriteFmt("Testing FloatMul generic dispatch\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:337:
Str text = StrInit(&alloc.base);
FloatMul(&result_value, &a, &b);
text = FloatToStr(&result_value);
bool result = ZstrCompare(StrBegin(&text), "3") == 0;- In
Math.c:342:
StrDeinit(&text);
FloatMul(&result_value, &a, &whole);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3") == 0);- In
Math.c:347:
StrDeinit(&text);
FloatMul(&result_value, &a, 2u);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "3") == 0);- In
Math.c:352:
StrDeinit(&text);
FloatMul(&result_value, &a, -2);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "-3") == 0);- In
Math.c:357:
StrDeinit(&text);
FloatMul(&result_value, &a, 0.5f);
text = FloatToStr(&result_value);
result = result && (ZstrCompare(StrBegin(&text), "0.75") == 0);- In
Math.c:573:
// gt_to_ge mutant the guard fires LOG_FATAL and the process aborts -> killed.
static bool test_m10_mul_exp_max_boundary(void) {
WriteFmt("Testing exponent-sum at INT64_MAX boundary (FloatMul)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:581:
Float r = FloatInit(&alloc.base);
bool ok = FloatMul(&r, &a, &b);
ok = ok && (FloatExponent(&r) == INT64_MAX);- In
Math.c:595:
// lt_to_le mutant aborts -> killed.
static bool test_m10_mul_exp_min_boundary(void) {
WriteFmt("Testing exponent-sum at INT64_MIN boundary (FloatMul)\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:603:
Float r = FloatInit(&alloc.base);
bool ok = FloatMul(&r, &a, &b);
ok = ok && (FloatExponent(&r) == INT64_MIN);- In
Math.c:1118:
Float r = FloatFromStr("314159265", &dbg.base); // pre-populated dest
bool ok = FloatMul(&r, &a, &b);
FloatDeinit(&a);- In
Math.c:1312:
Int b = IntFrom(4, &dbg.base);
bool ok = FloatMul(&r, &a, &b);
FloatDeinit(&a);- In
Math.c:1328:
Float r = FloatInit(&dbg.base);
bool ok = FloatMul(&r, &a, 4u);
FloatDeinit(&a);- In
Math.c:1343:
Float r = FloatInit(&dbg.base);
bool ok = FloatMul(&r, &a, -4);
FloatDeinit(&a);- In
Math.c:1358:
Float r = FloatInit(&dbg.base);
bool ok = FloatMul(&r, &a, 0.5f);
FloatDeinit(&a);- In
Math.c:1373:
Float r = FloatInit(&dbg.base);
bool ok = FloatMul(&r, &a, 0.25);
FloatDeinit(&a);- In
Convert.c:284:
Float canon = FloatFromStr("0", &alloc.base);
bool ok = FloatMul(&product, &zero, &neg);
ok = ok && FloatIsZero(&product);
Last updated on