Files
AutoControlSystem-git/test_ui.py

15 lines
319 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

output_n = 7
io_bit = 5
def is_bit_set(n, position):
"""
检查整数 n 的第 position 位是否为 1
:param n: 整数
:param position: 从右往左数的位0 表示最低位
:return: True 表示该位是 1否则为 False
"""
return (n >> position) & 1 == 1
print(is_bit_set(7,3))