Search Postgresql Archives

Re: Logic AND between some strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux