Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: BIN()


  • From: Andrew Dunstan <andrew(at)dunslane(dot)net>
  • To: Michael Fuhr <mike(at)fuhr(dot)org>
  • Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Hackers <pgsql-hackers(at)postgresql(dot)org>
  • Subject: Re: BIN()
  • Date: Tue, 29 Nov 2005 23:45:18 -0500
  • Message-id: <438D2E5E(dot)2020508(at)dunslane(dot)net>



Michael Fuhr wrote:

On Tue, Nov 29, 2005 at 09:46:13PM -0500, Andrew Dunstan wrote:
create or replace function bin(bigint) returns text language plperl as $$

my $arg = $_[0] + 0;
my $res = "";
while($arg)
{
  $res = ($arg % 2) . $res;
  $arg >>= 1;
}
return $res;

$$;

Any reason not to use sprintf("%b", $_[0])?


TIMTOWTDI, as we have seen

(also I had forgotten %b if I ever knew it)

cheers

andrew



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group