-
Notifications
You must be signed in to change notification settings - Fork 1
/
binary.py
89 lines (57 loc) · 1.46 KB
/
binary.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"""
Binary Number Class
Reference: https://docs.python.org/2.7/reference/datamodel.html#emulating-numeric-types
"""
class binary (object):
val = None
def __init__(self, i):
self.val = i
# Comparison
def __lt__(self, other):
return self.val < other.val
def __le__(self, other):
return self.val <= other.val
def __eq__(self, other):
return self.val == other.val
def __ne__(self, other):
return self.val != other.val
def __gt__(self, other):
return self.val > other.val
def __ge__(self, other):
return self.val >= other.val
# Math
def __add__(self, other):
return self.val + other.val
def __sub__(self, other):
return self.val - other.val
def __mul__(self, other):
pass
def __floordiv__(self, other):
pass
def __div__(self, other):
pass
def __mod__(self, other):
pass
def __divmod__(self, other):
pass
def __pow__(self, other[, modulo]):
pass
# Shifting
def __lshift__(self, other):
pass
def __rshift__(self, other):
pass
# Logical Operations
def __and__(self, other):
pass
def __xor__(self, other):
pass
def __or__(self, other):
pass
# Item Selection
def __getitem__(self, index):
pass
def __setitem__(self, index, value):
pass
def __delitem__(self, index):
pass