Re: [GENERAL] Bitmask trickiness

2010-07-23 Thread Howard Rogers
On Fri, Jul 23, 2010 at 3:02 PM, Scott Marlowe scott.marl...@gmail.com wrote: If you mean, did I read the bit in the doco where it said nothing at all in the 'these are great advantages' style I've just described, but instead makes the fairly obvious point that a bit string takes 8 bits to

Re: [GENERAL] Bitmask trickiness

2010-07-23 Thread Stephen Cook
On 7/23/2010 2:38 AM, Howard Rogers wrote: Still doesn't answer the precise, specific technical question I actually asked, though, does it?! Which was answered by Stephen Cook was it not? I.e. use plain old equals? Maybe I should assume you haven't read the thread, then?! God knows what

Re: [GENERAL] Bitmask trickiness

2010-07-23 Thread Alban Hertroys
I thought to do select * from coloursample where colour 10 = 10; ...but that's not right, because it finds the third record is a match. What's not entirely clear to me is whether you only want to find colours that have BOTH Yellow and Orange set and nothing else, or colours that have

Re: [GENERAL] Bitmask trickiness

2010-07-23 Thread Stephen Cook
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

Re: [GENERAL] Bitmask trickiness

2010-07-23 Thread Howard Rogers
On Fri, Jul 23, 2010 at 7:57 PM, Stephen Cook scli...@gmail.com wrote: 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

Re: [GENERAL] Bitmask trickiness

2010-07-23 Thread Howard Rogers
Hate to interrupt your flame war, and I apologize for not being precise in my meaning first try... You don't need any bitwise anything to compare two bitmasks-hiding-in-integers, just check for equality. Instead of select * from coloursample where colour 10 = 10; just try select * from

Re: [GENERAL] Bitmask trickiness

2010-07-23 Thread Howard Rogers
On Fri, Jul 23, 2010 at 6:17 PM, Alban Hertroys dal...@solfertje.student.utwente.nl wrote: I thought to do select * from coloursample where colour 10 = 10; ...but that's not right, because it finds the third record is a match. What's not entirely clear to me is whether you only want to

Re: [GENERAL] Bitmask trickiness

2010-07-23 Thread Greg Smith
Howard Rogers wrote: That's the point: you've assumed something you needn't have. You seem to have assumed that Scott was trying to be a jerk here, when he was just trying to help you out by suggesting a feature in PostgreSQL you may not have been familiar with, one that makes this

Re: [GENERAL] Bitmask trickiness

2010-07-23 Thread Scott Marlowe
On Fri, Jul 23, 2010 at 10:04 AM, Greg Smith g...@2ndquadrant.com wrote: P.S. This little I've been doing this for X long pissing game is going to end making everyone look like n00bs when Tom gets back. No pissing match on my end. I honestly feel more comfortable working with these kinds of

Re: [GENERAL] Bitmask trickiness

2010-07-23 Thread John R Pierce
the universal solution is a AND with one mask (which has a 1 in every position you wish to test for and a zero in each position you wish to ignore) and an XOR with another mask (that has a 1 in each position that you want to test for a 1 and a zero in each position that you wish to test for

Re: [GENERAL] Bitmask trickiness

2010-07-22 Thread Howard Rogers
On Thu, Jul 22, 2010 at 1:02 PM, Scott Marlowe scott.marl...@gmail.com wrote: Why on Earth would I want to store this sort of stuff in a bit string?! Because you are manipulating bits and not integers?  I guess there are 10 kinds of people, those who like think in binary and those who

Re: [GENERAL] Bitmask trickiness

2010-07-22 Thread Peter Hunsberger
On Wed, Jul 21, 2010 at 11:13 PM, Howard Rogers h...@diznix.com wrote: On Thu, Jul 22, 2010 at 1:02 PM, Scott Marlowe scott.marl...@gmail.com wrote: Why on Earth would I want to store this sort of stuff in a bit string?! Because you are manipulating bits and not integers?  I guess

Re: [GENERAL] Bitmask trickiness

2010-07-22 Thread Peter Hunsberger
On Thu, Jul 22, 2010 at 4:09 PM, Howard Rogers h...@diznix.com wrote: On Fri, Jul 23, 2010 at 12:35 AM, Peter Hunsberger peter.hunsber...@gmail.com wrote: On Wed, Jul 21, 2010 at 11:13 PM, Howard Rogers h...@diznix.com wrote: there's a room-full of users who can look at code '4097' and

Re: [GENERAL] Bitmask trickiness

2010-07-22 Thread Howard Rogers
On Fri, Jul 23, 2010 at 12:35 AM, Peter Hunsberger peter.hunsber...@gmail.com wrote: On Wed, Jul 21, 2010 at 11:13 PM, Howard Rogers h...@diznix.com wrote: On Thu, Jul 22, 2010 at 1:02 PM, Scott Marlowe scott.marl...@gmail.com wrote: Why on Earth would I want to store this sort of stuff

Re: [GENERAL] Bitmask trickiness

2010-07-22 Thread Scott Marlowe
On Thu, Jul 22, 2010 at 3:09 PM, Howard Rogers h...@diznix.com wrote: On Fri, Jul 23, 2010 at 12:35 AM, Peter Hunsberger peter.hunsber...@gmail.com wrote: On Wed, Jul 21, 2010 at 11:13 PM, Howard Rogers h...@diznix.com wrote: On Thu, Jul 22, 2010 at 1:02 PM, Scott Marlowe

Re: [GENERAL] Bitmask trickiness

2010-07-22 Thread Scott Marlowe
On Thu, Jul 22, 2010 at 10:27 PM, Howard Rogers h...@diznix.com wrote: On Fri, Jul 23, 2010 at 8:37 AM, Scott Marlowe scott.marl...@gmail.com wrote: On Thu, Jul 22, 2010 at 3:09 PM, Howard Rogers h...@diznix.com wrote: On Fri, Jul 23, 2010 at 12:35 AM, Peter Hunsberger

Re: [GENERAL] Bitmask trickiness

2010-07-22 Thread Howard Rogers
On Fri, Jul 23, 2010 at 8:37 AM, Scott Marlowe scott.marl...@gmail.com wrote: On Thu, Jul 22, 2010 at 3:09 PM, Howard Rogers h...@diznix.com wrote: On Fri, Jul 23, 2010 at 12:35 AM, Peter Hunsberger peter.hunsber...@gmail.com wrote: On Wed, Jul 21, 2010 at 11:13 PM, Howard Rogers

[GENERAL] Bitmask trickiness

2010-07-21 Thread Howard Rogers
Suppose 1=Red, 2=Yellow, 4=Green and 8=Orange. Now suppose the following data structures and rows exist: create table coloursample (recid integer, colour integer, descript varchar); insert into coloursample values (1,2,'Yellow only'); insert into coloursample values (2,10,'Yellow and Orange');

Re: [GENERAL] Bitmask trickiness

2010-07-21 Thread Scott Marlowe
On Tue, Jul 20, 2010 at 9:59 PM, Howard Rogers h...@diznix.com wrote: Suppose 1=Red, 2=Yellow, 4=Green and 8=Orange. Now suppose the following data structures and rows exist: create table coloursample (recid integer, colour integer, descript varchar); insert into coloursample values

Re: [GENERAL] Bitmask trickiness

2010-07-21 Thread Yeb Havinga
Howard Rogers wrote: insert into coloursample values (2,10,'Yellow and Orange'); But how do I find records which are ONLY yellow and orange what about select * from coloursample where colour = 10; regards, Yeb Havinga -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org)

Re: [GENERAL] Bitmask trickiness

2010-07-21 Thread Stephen Cook
On 7/20/2010 11:59 PM, Howard Rogers wrote: But how do I find records which are ONLY yellow and orange, and exclude records which have some other colour mixed in, in one simple query without a lot of 'not this, not that' additions, and without using multiple separate AND tests to nail it down?

Re: [GENERAL] Bitmask trickiness

2010-07-21 Thread Howard Rogers
On Wed, Jul 21, 2010 at 9:17 PM, Mathieu De Zutter math...@dezutter.org wrote: On Wed, Jul 21, 2010 at 5:59 AM, Howard Rogers h...@diznix.com wrote: It's also easy to find records which have either some yellow or some orange (or both) in them: select * from coloursample where colour 100;

Re: [GENERAL] Bitmask trickiness

2010-07-21 Thread Scott Marlowe
On Wed, Jul 21, 2010 at 4:41 AM, Howard Rogers h...@diznix.com wrote: On Wed, Jul 21, 2010 at 6:08 PM, Scott Marlowe scott.marl...@gmail.com wrote: On Tue, Jul 20, 2010 at 9:59 PM, Howard Rogers h...@diznix.com wrote: Suppose 1=Red, 2=Yellow, 4=Green and 8=Orange. Now suppose the following

Re: [GENERAL] Bitmask trickiness

2010-07-21 Thread Scott Marlowe
On Wed, Jul 21, 2010 at 9:02 PM, Scott Marlowe scott.marl...@gmail.com wrote: If the fifth bit means one thing, and the 7th bit means something else, quick which of the following have the fifth bit set and the 7th bit off: That should be fifth bit off and 7th bit on up there ^^^ 01001101