Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code/comment disagree in bits_util.py #10

Open
RossBoylan opened this issue May 15, 2020 · 0 comments
Open

code/comment disagree in bits_util.py #10

RossBoylan opened this issue May 15, 2020 · 0 comments

Comments

@RossBoylan
Copy link

In the definition of fls:

    # gradually set all bits right of MSB
    # this technique is called 'bit smearing'
    # if ipv6, max bit index we want to smear is 2^7=64, 
    # otherwise it's 2^4=16
    max_power_of_2 = 7 if v6 else 5
    n = val | val >> 1
    for i in range(1, max_power_of_2+1):
        n |= n >> 2**i

The comment says the max index to smear is 2^4 for IPv4, but the next line says it's 2^5.
I don't know which is correct, though I'd guess it's the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant