X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 71059D1B8B9 for ; Mon, 17 Nov 2003 15:18:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 83051-07 for ; Mon, 17 Nov 2003 11:18:17 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 8CFC1D1B50A for ; Mon, 17 Nov 2003 11:18:13 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 064F23549A; Mon, 17 Nov 2003 07:18:18 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 04D2335449; Mon, 17 Nov 2003 07:18:18 -0800 (PST) Date: Mon, 17 Nov 2003 07:18:18 -0800 (PST) From: Stephan Szabo To: Yasir Malik Cc: pgsql-sql@postgresql.org Subject: Re: Addition and subtraction on BIT type In-Reply-To: Message-ID: <20031117071700.G94696@megazone.bigpanda.com> References: <20031116213918.P81284@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/196 X-Sequence-Number: 16011 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);