Re: Logic AND between some strings

From: Bill Thoen <bthoen(at)gisnet(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Logic AND between some strings
Date: 2011-03-07 19:32:46
Message-ID: 4D7532DE.1070701@gisnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Just to make sure, you're asking for the logical AND, not the bitwise
AND? In other words you're not talking about getting into bit shifting
with << and >> and masking with &?

For the logical AND, you need to use expressions that evaluate to TRUE
or FALSE, and follow the rules in this "truth table":

Expr 1 Expr 2 AND returns
true true true
true false false
false true false
false false false

like 01100010 == 00001100 AND 01100010 > 00001100 would evaluate to
false AND true (depending on how you interpret these bitstrings), and so
that evaluates to false. If you're dealing with bitstrings (text made up
of only zeros and ones), then I'd implement this by just using text
comparisions, since bitstrings are just text and have the same
comparision behavior as the unsigned integers they could represent.

On 3/7/2011 7:25 AM, yagru_alvarez wrote:
> I want to make a Logic AND between some strings of 0s and 1s .. Here
> you have an example:
>
> 1-> 01100010
> 2-> 00001100
>
> I wanto to make a LOGIC AND between 01100010 and 00001100.
>
> I' m working with C++, I need some code to have an idea about how I
> can perform that.
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2011-03-07 19:36:27 Re: Why count(*) doest use index?
Previous Message David Johnston 2011-03-07 18:49:22 Re: Understanding of LOCK and pg_sleep interaction