Re: BIN() - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: BIN()
Date
Msg-id 438D2E5E.2020508@dunslane.net
Whole thread Raw
In response to Re: BIN()  (Michael Fuhr <mike@fuhr.org>)
List pgsql-hackers

Michael Fuhr wrote:

>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])?
>
>  
>

TIMTOWTDI, as we have seen

(also I had forgotten %b if I ever knew it)

cheers

andrew


pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: BIN()
Next
From: sandeep satpal
Date:
Subject: How to add our functions in postgres