Re: Addition and subtraction on BIT type

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Yasir Malik <ymalik(at)heineken(dot)cs(dot)stevens-tech(dot)edu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Addition and subtraction on BIT type
Date: 2003-11-17 15:18:18
Message-ID: 20031117071700.G94696@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 17 Nov 2003, Yasir Malik wrote:

> 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.

I think you need to use substring, probably something like:
select substring(9::bit(32) from 29 for 4);

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message ritchie turner 2003-11-17 15:32:17 COPY
Previous Message Stephan Szabo 2003-11-17 15:16:51 Re: strange "not deferrable" behaviour