aureooms/js-integer-little-endian

View on GitHub
src/0-legacy/others/pow/pow.js

Summary

Maintainability
A
1 hr
Test Coverage
/**
 * Computes pow(a, b) using naive exponentiation.
 *
 */

export function __pow__ (alloc, isnotzero, setone, iseven, div2, minus1) {

    var pow = function (a, ai, aj, b, bi, bj, c, ci, cj) {

        var t, m;

        setone(c, ci, cj);

        while (isnotzero(b, bi, bj)) {

            mul(c, ci, cj, a, ai, aj, c, ci, cj);

            minus1(b, bi, bj, b, bi, bj);
        }

    };
}