res Law ]
x * ( (X+y)*(x+Y) ) [ inversion]
x * (X+y) * (x+Y) [ associative]
(xX+xy)*(x+Y) [ distributive ]
xy*(x+Y) [ xX = 0 ]
xy+xyY [ distrib ]
xy[yY = 0]
So,
x &= x-1
On 19 Jun 2008, at 17:37, Matimus wrote:
On Jun 19, 4:27 pm, godavemon <[EMAIL PROTECTED]> wrote:
I need to
godavemon wrote:
I need to calculate the Hamming Distance of two integers. The hamming
distance is the number of bits in two integers that don't match.
...
What about letting the bits count themselves in a parallel adding scheme:
def hamming(i, j):
i ^= j
i = ((i&044
Great thanks!
On Jun 19, 5:37 pm, Matimus <[EMAIL PROTECTED]> wrote:
> On Jun 19, 4:27 pm, godavemon <[EMAIL PROTECTED]> wrote:
>
>
>
> > I need to calculate the Hamming Distance of two integers. The hamming
> > distance is the number of bits in two integ
Awesome! Thanks a lot.
On Jun 19, 5:00 pm, Mensanator <[EMAIL PROTECTED]> wrote:
> On Jun 19, 6:27 pm, godavemon <[EMAIL PROTECTED]> wrote:
>
>
>
> > I need to calculate the Hamming Distance of two integers. The hamming
> > distance is the number of bits
Non-recursive, 8-bit block table lookup version:
def ham(a, b, ht=[hamdist(a,0) for a in range(256)]):
x = a ^ b
dist = 0
while x:
dist += ht[x & 255]
x >>= 8
return dist
Raymond
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 19, 4:27 pm, godavemon <[EMAIL PROTECTED]> wrote:
> I need to calculate the Hamming Distance of two integers. The hamming
> distance is the number of bits in two integers that don't match. I
> thought there'd be a function in math or scipy but i haven't bee
On Jun 19, 6:27 pm, godavemon <[EMAIL PROTECTED]> wrote:
> I need to calculate the Hamming Distance of two integers. The hamming
> distance is the number of bits in two integers that don't match. I
> thought there'd be a function in math or scipy but i haven't bee
godavemon wrote:
I need to calculate the Hamming Distance of two integers. The hamming
distance is the number of bits in two integers that don't match. I
thought there'd be a function in math or scipy but i haven't been able
to find one. This is my function but it seems like th
On Jun 20, 9:27 am, godavemon <[EMAIL PROTECTED]> wrote:
> I need to calculate the Hamming Distance of two integers. The hamming
> distance is the number of bits in two integers that don't match. I
> thought there'd be a function in math or scipy but i haven't bee
On Jun 19, 4:27 pm, godavemon <[EMAIL PROTECTED]> wrote:
> I need to calculate the Hamming Distance of two integers. The hamming
> distance is the number of bits in two integers that don't match. I
> thought there'd be a function in math or scipy but i haven't bee
I need to calculate the Hamming Distance of two integers. The hamming
distance is the number of bits in two integers that don't match. I
thought there'd be a function in math or scipy but i haven't been able
to find one. This is my function but it seems like there should be a
fa
11 matches
Mail list logo