Ubuntu Pastebin

Paste from jonas at Tue, 2 Jun 2015 17:50:43 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
tst_fail    = 0b00010000
tst_ok1     = 0b10000000
tst_ok2     = 0b00000100

def check(tst):
    mask = 0xFF ^ tst
    print "{0:b}".format(tst)
    print "{0:b}".format(mask)
    print "{0:b}".format(mask & tst)
    access  = 0b10001111
    result = mask & access
    if (result):
        return True
    else:
        return False

print check(tst_fail)
print check(tst_ok1)
print check(tst_ok2)
Download as text