Re: BIN() - Mailing list pgsql-hackers

From Michael Fuhr
Subject Re: BIN()
Date
Msg-id 20051130025758.GA32098@winnie.fuhr.org
Whole thread Raw
In response to Re: BIN()  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: BIN()
Re: BIN()
Re: BIN()
List 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


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: BIN()
Next
From: Michael Fuhr
Date:
Subject: Re: BIN()