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: Tue, 29 Nov 2005 19:57:58 -0700
- Message-id: <20051130025758(dot)GA32098(at)winnie(dot)fuhr(dot)org>
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
Home |
Main Index |
Thread Index