Skip to content

IntMul

Description

Generic multiplication convenience macro.

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)

  IntMul(&product, &value, 10u);

Success

Returns true; *result holds a * b.

Failure

Returns false if an intermediate allocation fails; *result is unchanged.

Usage example (Cross-references)

Usage examples (Cross-references)
    
    bool test_int_mul(void) {
        WriteFmt("Testing IntMul\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Int result_value = IntInit(&alloc.base);
    
        IntMul(&result_value, &a, &b);
    
        bool result = IntToU64(&result_value) == 126;
    
    bool test_int_mul_scalar(void) {
        WriteFmt("Testing IntMul generic dispatch\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Str text         = StrInit(&alloc.base);
    
        IntMul(&result_value, &value, 25u);
        text = IntToStr(&result_value);
    
    bool test_int_mul_zero(void) {
        WriteFmt("Testing IntMul with zero\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Int result_value = IntInit(&alloc.base);
    
        IntMul(&result_value, &a, &b);
    
        bool result = IntIsZero(&result_value);
Last updated on