Power
Base.ispow2 — Function
ispow2(n::Number) -> BoolTest whether n is an integer power of two.
See also count_ones, prevpow, nextpow.
Examples
julia> ispow2(4)
true
julia> ispow2(5)
false
julia> ispow2(4.5)
false
julia> ispow2(0.25)
true
julia> ispow2(1//8)
trueBase.prevpow — Function
prevpow(a, x)The largest a^n not greater than x, where n is a non-negative integer. a must be greater than 1, and x must not be less than 1.
Examples
julia> prevpow(2, 7)
4
julia> prevpow(2, 9)
8
julia> prevpow(5, 20)
5
julia> prevpow(4, 16)
16Base.nextpow — Function
nextpow(a, x)The smallest a^n not less than x, where n is a non-negative integer. a must be greater than 1, and x must be greater than 0.
See also prevpow.
Examples
julia> nextpow(2, 7)
8
julia> nextpow(2, 9)
16
julia> nextpow(5, 20)
25
julia> nextpow(4, 16)
16Base.powermod — Function
powermod(x::Integer, p::Integer, m)Compute $x^p \pmod m$.
Examples
julia> powermod(2, 6, 5)
4
julia> mod(2^6, 5)
4
julia> powermod(5, 2, 20)
5
julia> powermod(5, 2, 19)
6
julia> powermod(5, 3, 19)
11