aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2020-09-30 15:35:05 +0200
committerAndrew Kelley <andrew@ziglang.org>2020-10-04 02:24:40 -0400
commit538d485782629a358c2dd0f8e34d74813e3c9526 (patch)
treed67182c6085d69a63d3f495d0c180b2b149d52c7 /src/Compilation.zig
parent2de53592a1d84a1476f662e20d7339d25d4716fe (diff)
downloadzig-538d485782629a358c2dd0f8e34d74813e3c9526.tar.gz
zig-538d485782629a358c2dd0f8e34d74813e3c9526.zip
std: Add pow(a,b) for big ints
Implemented following Knuth's "Evaluation of Powers" chapter in TAOCP, some extra complexity is needed to make sure there's no aliasing and avoid allocating too many limbs. A brief example to illustrate why the last point is important: consider 10^123, since 10 is well within the limits of a single limb we can safely say that the result will surely fit in: ⌈log2(10)⌉ bit * 123 = 492 bits = 7 limbs A naive calculation using only the number of limbs yields: 1 limb * 123 = 123 limbs The space savings are noticeable.
Diffstat (limited to 'src/Compilation.zig')
0 files changed, 0 insertions, 0 deletions