X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 45E9DD1B1CB for ; Thu, 10 Jun 2004 17:24:23 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32255-03 for ; Thu, 10 Jun 2004 20:24:20 +0000 (GMT) Received: from web13804.mail.yahoo.com (web13804.mail.yahoo.com [216.136.175.14]) by svr1.postgresql.org (Postfix) with SMTP id 28C55D1B1A1 for ; Thu, 10 Jun 2004 17:24:17 -0300 (ADT) Message-ID: <20040610202415.89117.qmail@web13804.mail.yahoo.com> Received: from [216.173.173.66] by web13804.mail.yahoo.com via HTTP; Thu, 10 Jun 2004 13:24:15 PDT Date: Thu, 10 Jun 2004 13:24:15 -0700 (PDT) From: Chris Gamache Reply-To: cgg007@yahoo.com Subject: Re: Converting integer to binary To: Bruno Wolff III , Stephen Quinney Cc: pgsql-sql@postgresql.org In-Reply-To: <20040610182756.GA22247@wolff.to> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200406/92 X-Sequence-Number: 18037 Once upon a time in PostgreSQL there was a function : bitfromint4 ... Any idea where it has disappeared to? You can do # select B'10101101'::int4; int4 ------ 173 (1 row) but you want to go # select 173::varbit; which is what bitfromint4 used to do. CG --- Bruno Wolff III wrote: > On Thu, Jun 10, 2004 at 14:52:41 +0100, > Stephen Quinney wrote: > > > > I have searched around but I cannot see any standard way in PostgreSQL > > to convert from an integer into a binary representation. > > > > Now I have an algorithm to do it so I could write an SQL function, I > > guess. If there's a standard way to do it though that would be quite nice. > > There doesn't seem to currently be a function that does this. to_char > would be the logical place since that is what is used to convert various > numeric types to strings with a decimal representation. > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/