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

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 (view raw or flat)
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

pgsql-hackers by date

Next:From: Michael FuhrDate: 2005-11-30 03:02:51
Subject: Re: BIN()
Previous:From: Andrew DunstanDate: 2005-11-30 02:46:13
Subject: Re: BIN()

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group