Skip to content

IntPow

IntPow

Description

Generic exponentiation convenience macro.

Parameters

Name Direction Description
result out Destination for the result
base in Base value
exponent in Exponent selected through generic dispatch

Usage example (from documentation)

  IntPow(&power, &base, 20u);

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    void(IntPow)(Int *result, Int *base, Int *exponent) {
        ValidateInt(result);
        ValidateInt(base);
    
    bool test_int_pow_generic(void) {
        WriteFmt("Testing IntPow generic dispatch\n");
    
        Int base = IntFrom(7);
        Str text = StrInit();
    
        IntPow(&result_value, &base, 20u);
        text   = IntToStr(&result_value);
        bool result = strcmp(text.data, "79792266297612001") == 0;
    
        StrDeinit(&text);
        IntPow(&result_value, &base, exponent);
        text   = IntToStr(&result_value);
        result = result && (strcmp(text.data, "79792266297612001") == 0);
    /// TAGS: Int, Math, Power, Exponentiation
    ///
    void (IntPow)(Int *result, Int *base, Int *exponent);
    ///
    /// Divide one integer by another using floor division.
                (exponent),                                                                                                \
                Int: MISRA_PRIV_IntPowValue,                                                                               \
                Int *: IntPow,                                                                                             \
                const Int *: MISRA_PRIV_IntPowConst,                                                                       \
                unsigned char: MISRA_PRIV_IntPowU64,                                                                       \
Last updated on