Re: bit strings - anyone working on them?

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: "Christopher Kings-Lynne" <chriskl(at)familyhealth(dot)com(dot)au>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: bit strings - anyone working on them?
Date: 2003-04-23 01:28:14
Message-ID: 5.1.0.14.0.20030423111934.0580d038@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 |/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Neil Conway 2003-04-23 01:30:24 Re: CLOSE command tag
Previous Message Christopher Kings-Lynne 2003-04-23 01:15:49 Re: bit strings - anyone working on them?