Numbers.Helper (numbers v5.2.5)

Copy Markdown

Helper functions that might make the implementation of Numbers for your own numberlike types easier.

Summary

Functions

Performs 'Exponentiation by Squaring', which is a reasonably fast algorithm to compute integer powers, by performing log(n) multiplication steps.

Functions

pow_by_sq(num, integer_power)

Performs 'Exponentiation by Squaring', which is a reasonably fast algorithm to compute integer powers, by performing log(n) multiplication steps.

Depends on an implementation existing of Numbers.Protocols.Multiplication, as well as (to support negative powers) an implementation of Numbers.Protocols.Division.