Re: Bitmask trickiness

From: Stephen Cook <sclists(at)gmail(dot)com>
To: Howard Rogers <hjr(at)diznix(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Bitmask trickiness
Date: 2010-07-23 09:57:53
Message-ID: 4C4967A1.2070906@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 7/23/2010 5:33 AM, Howard Rogers wrote:
> ...so select * from table where 21205 | 4097 = 21205 would correctly
> grab that record. So I'm assuming you mean the 'stored value' should
> be on both sides of the equals test. If so, that would indeed seem to
> be the ultimate answer to the question (though I wouldn't myself call
> it a 'plain old equals' :-) )
>
>> Hope I was clearer this time. Originally I just fired off a quickie email to
>> get you past your coder's block.
>
> I do indeed think the magic of "BIT OR" is the missing ingredient I
> was looking for, and I very much appreciate your help leading me to
> it. My apologies for being too dense to spot what you were talking
> about before.

I think I misunderstood you the whole time actually, or maybe was
injecting some of my other thoughts into your problem. I figured you
meant you wanted to find records where your probe value has exactly the
same bit pattern as your stored value (probe bits, and only probe bits,
set; hence the "plain old equals"). Rather (and I just confirmed this
looking at the OP) you want any records where the stored value has all
of the probe value's bits set, regardless of the other bits in the
stored value.

So yeah, check if ORing the stored and probe values equals the stored value.

Oh well, even if I misread, glad to help you stumble upon what you
wanted eventually.

-- Stephen

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GÜNDÜZ 2010-07-23 10:11:28 Re: Centos 5.5 and Postgres 9.0.beta3 install errors
Previous Message Tom Robst 2010-07-23 09:50:17 Centos 5.5 and Postgres 9.0.beta3 install errors