Re: BIN() - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Re: BIN()
Date
Msg-id 438D16A5.4020203@familyhealth.com.au
Whole thread Raw
In response to Re: BIN()  (Michael Fuhr <mike@fuhr.org>)
List pgsql-hackers
>>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])?
> 

All very well and good, but it has to be PL/SQL preferably or PL/pgSQL.  I can write it in PL/PGSQL easily enough I
guessbut I was hoping 
 
there was a neato shortcut.

Chris



pgsql-hackers by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: BIN()
Next
From: Christopher Kings-Lynne
Date:
Subject: Re: BIN()