From: | Yasir Malik <ymalik(at)heineken(dot)cs(dot)stevens-tech(dot)edu> |
---|---|
To: | PostgreSQL <pgsql-sql(at)postgresql(dot)org> |
Cc: | sszabo(at)megazone(dot)bigpanda(dot)com |
Subject: | Re: Addition and subtraction on BIT type |
Date: | 2003-11-17 14:32:31 |
Message-ID: | Pine.LNX.4.58.0311170931510.10192@heineken.cs.stevens-tech.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Thank you for your reply.
select int4(b'1001')::bit(32); gives the same result as what you gave.
select int4(b'1001')::bit(4); gives the upper four bits, which are all
zeroes. How would I get the lower four bits? I building bitmaps using
plpgsql, and therefore, I will be doing a lot bit manipulation.
Thanks,
Yasir
On Sun, 16 Nov 2003, Stephan Szabo wrote:
> Date: Sun, 16 Nov 2003 21:40:45 -0800 (PST)
> From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
> To: Yasir Malik <ymalik(at)cs(dot)stevens-tech(dot)edu>
> Cc: pgsql-sql(at)postgresql(dot)org
> Subject: Re: [SQL] Addition and subtraction on BIT type
>
> On Sun, 16 Nov 2003, Yasir Malik wrote:
>
> > I think I am almost at a solution to my last question. I can do
> > select int4(a) from test;
> > to convert to an integer. So now addition and
> > subtraction can be done between bit types. But how do I convert back to
> > BIT type? If I do
> > select bit(int4(b'1001'));
> >
> > I get the following message:
> > ERROR: parser: parse error at or near "int4" at character 12
> >
> > Can anyone tell me why the bit function is not working? It's under the
> > pg_catalog schema.
>
> It's also the name of a type that takes a precision in parentheses, so
> you'd have to say "bit"(...) with the quotes. As a note, I think
> that's going to effectively return you a bit(32), so
>
> sszabo=# select "bit"(int4(b'1001'));
> bit
> ----------------------------------
> 00000000000000000000000000001001
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2003-11-17 15:16:51 | Re: strange "not deferrable" behaviour |
Previous Message | Yasir Malik | 2003-11-17 14:10:37 | Re: Addition and subtraction on BIT type |