-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbit_comparator.py
More file actions
32 lines (30 loc) · 828 Bytes
/
Copy pathbit_comparator.py
File metadata and controls
32 lines (30 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class BitComparator:
"""
Compares two bits using boolean algebra
"""
@staticmethod
def compare_bits_xor(first_bit, second_bit):
"""
Applies an 'xor' (exclusive or) boolean operation for the
given two bits
:param first_bit:
:type first_bit: int
:param second_bit:
:type second_bit: int
:return: xor_result
:rtype: bool
"""
return first_bit ^ second_bit
@staticmethod
def compare_bits_and(first_bit, second_bit):
"""
Applies an 'and' boolean operation for the
given two bits
:param first_bit:
:type first_bit: int
:param second_bit:
:type second_bit: int
:return: and_result
:rtype: bool
"""
return first_bit and second_bit