Re: Logic AND between some strings - Mailing list pgsql-general

From Bill Thoen
Subject Re: Logic AND between some strings
Date
Msg-id 4D7532DE.1070701@gisnet.com
Whole thread Raw
In response to Logic AND between some strings  (yagru_alvarez <jmalvarez@estudiantes.uci.cu>)
List 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.
>


pgsql-general by date:

Previous
From: "David Johnston"
Date:
Subject: Re: Understanding of LOCK and pg_sleep interaction
Next
From: Scott Marlowe
Date:
Subject: Re: Why count(*) doest use index?