Brian
Brian

Reputation: 14836

Btest function in fortran, is there any equivalent in python?

I would like to use the equivalent of the btest function in Fortran in Python. Do you know if there's something I could use?

Upvotes: 1

Views: 554

Answers (1)

Jon Clements
Jon Clements

Reputation: 142136

I think something like:

def btest(i, pos):
    return i & (1 << pos)

Upvotes: 3

Related Questions