Skip to content

Instantly share code, notes, and snippets.

View ecree-solarflare's full-sized avatar

Edward Cree ecree-solarflare

View GitHub Profile
@ecree-solarflare
ecree-solarflare / aligner.py
Last active May 18, 2017 18:19
Track alignment (and other known-bits properties) through arithmetic
#!/usr/bin/python2
NUM_BITS = 16
ALL_BITS = (1 << NUM_BITS) - 1
def cpl(x):
return (~x)&ALL_BITS
class AlignedNumber(object):
def __init__(self, mask=ALL_BITS, value=0):