is_power_of_two Function

public pure function is_power_of_two(N) result(value)

Arguments

Type IntentOptional Attributes Name
integer(kind=isp), intent(in) :: N

Return Value logical


Source Code

    pure function is_power_of_two(N) result(value)
        integer(isp), intent(in) :: N
        logical :: value

        if (N < 1) then
            value = .false.
        else
            value = (iand(N, N - 1) == 0)
        end if
    end function is_power_of_two