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 69B90D1B20D for ; Thu, 10 Jun 2004 10:52:42 -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 31394-05 for ; Thu, 10 Jun 2004 13:52:42 +0000 (GMT) Received: from tx3.oucs.ox.ac.uk (tx3.oucs.ox.ac.uk [163.1.2.167]) by svr1.postgresql.org (Postfix) with ESMTP id E821DD1B1A5 for ; Thu, 10 Jun 2004 10:52:37 -0300 (ADT) Received: from scan3.oucs.ox.ac.uk ([163.1.2.166] helo=localhost) by tx3.oucs.ox.ac.uk with esmtp (Exim 4.24) id 1BYPyz-0003nu-OK for pgsql-sql@postgresql.org; Thu, 10 Jun 2004 14:52:41 +0100 Received: from rx3.oucs.ox.ac.uk ([163.1.2.165]) by localhost (scan3.oucs.ox.ac.uk [163.1.2.166]) (amavisd-new, port 25) with ESMTP id 13807-06 for ; Thu, 10 Jun 2004 14:52:41 +0100 (BST) Received: from smtp1.herald.ox.ac.uk ([163.1.0.247]) by rx3.oucs.ox.ac.uk with esmtp (Exim 4.24) id 1BYPyz-0003nh-AZ for pgsql-sql@postgresql.org; Thu, 10 Jun 2004 14:52:41 +0100 Received: from mizar.oucs.ox.ac.uk ([163.1.15.107]) by smtp1.herald.ox.ac.uk with esmtp (Exim 3.35 #1) id 1BYPyz-0001PA-3z for pgsql-sql@postgresql.org; Thu, 10 Jun 2004 14:52:41 +0100 Received: from stephen by mizar.oucs.ox.ac.uk with local (Exim 3.36 #1 (Debian)) id 1BYPyz-0007hH-00 for ; Thu, 10 Jun 2004 14:52:41 +0100 Date: Thu, 10 Jun 2004 14:52:41 +0100 From: Stephen Quinney To: pgsql-sql@postgresql.org Subject: Converting integer to binary Message-ID: <20040610135240.GD27245@computing-services.oxford.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: Linux mizar 2.6.6 x-gpg-fingerprint: F934 244D 4E26 DBDE C9EF BFB7 2131 9B94 4C1A 5BE5 x-gpg-key: wwwkeys.uk.pgp.net User-Agent: Mutt/1.5.5.1+cvs20040105i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/83 X-Sequence-Number: 18028 I have searched around but I cannot see any standard way in PostgreSQL to convert from an integer into a binary representation. i.e. I want to do: 16 ==> 10000 32 ==> 100000 64 ==> 1000000 96 ==> 1100000 etc.. 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. Thanks in advance, Stephen Quinney