libzahl

big integer library
git clone git://git.suckless.org/libzahl
Log | Files | Refs | README | LICENSE

commit c1b7101b0f33b07c98b971b2dd075c068f319299
parent 346458c840dd1c4df9fdcf0749ff6a6c000e713e
Author: Mattias Andrée <maandree@kth.se>
Date:   Mon,  7 Mar 2016 07:36:29 +0100

A brief description of exponentiation by squaring

Signed-off-by: Mattias Andrée <maandree@kth.se>

Diffstat:
Msrc/zpow.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/zpow.c b/src/zpow.c @@ -8,6 +8,12 @@ void zpow(z_t a, z_t b, z_t c) { + /* + * Exponentiation by squaring. + * + * 7↑19 = 7↑10011₂ = 7↑2⁰ ⋅ 7↑2¹ ⋅ 7↑2⁴ where a↑2↑(n + 1) = (a↑2↑n)². + */ + size_t i, j, n, bits; zahl_char_t x;