Re: BIN()

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: BIN()
Date: 2005-11-30 02:57:58
Message-ID: 20051130025758.GA32098@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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])?

--
Michael Fuhr

In response to

  • Re: BIN() at 2005-11-30 02:46:13 from Andrew Dunstan

Responses

  • Re: BIN() at 2005-11-30 03:02:51 from Michael Fuhr
  • Re: BIN() at 2005-11-30 03:04:05 from Christopher Kings-Lynne
  • Re: BIN() at 2005-11-30 04:45:18 from Andrew Dunstan

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Fuhr 2005-11-30 03:02:51 Re: BIN()
Previous Message Andrew Dunstan 2005-11-30 02:46:13 Re: BIN()