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

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to