Re: bit strings - anyone working on them? - Mailing list pgsql-hackers

From Philip Warner
Subject Re: bit strings - anyone working on them?
Date
Msg-id 5.1.0.14.0.20030423111934.0580d038@mail.rhyme.com.au
Whole thread Raw
In response to Re: bit strings - anyone working on them?  ("Christopher Kings-Lynne" <chriskl@familyhealth.com.au>)
Responses Re: bit strings - anyone working on them?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
At 09:15 AM 23/04/2003 +0800, Christopher Kings-Lynne wrote:
>Do you right pad that 101? No way!!! You left pad it!

See my earlier post in this thread questioning which was the low order bit. 
The current implementation is schizophrenic about this: it seems to treat 
the left-hand bits as low order sometimes, and the right-hand bits as low 
order when converting integer. It can't make up it's mind if it is a string 
or a number.

If we treat left as low order, then:

1 | 10 => 10

Cast(8 as varbit(10)) => 0001000000
Cast(8 as varbit(32)) => 00010000000000000000000000000000
etc

Which, on the whole, makes more sense. It's just hard to get around the 
notion  of '10' being decimal 1, not 2.

Also, I think substring is the only way to extract bits, and I would expect:
    Substring(Cast(8 as bit(X)), 4,1)

should produce 1, which it does not. But if we adopt the left-bits-are-low 
philosophy, it works.

Don't get me wrong, I don't mind if we adopt left-bits-are-high, then we 
just need to change the way substring & padding works. No idea which is better.



----------------------------------------------------------------
Philip Warner                    |     __---_____
Albatross Consulting Pty. Ltd.   |----/       -  \
(A.B.N. 75 008 659 498)          |          /(@)   ______---_
Tel: (+61) 0500 83 82 81         |                 _________  \
Fax: (+61) 03 5330 3172          |                 ___________ |
Http://www.rhyme.com.au          |                /           \|                                 |    --________--
PGP key available upon request,  |  /
and from pgp5.ai.mit.edu:11371   |/



pgsql-hackers by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: Re: bit strings - anyone working on them?
Next
From: Neil Conway
Date:
Subject: Re: CLOSE command tag