Re: Converting integer to binary

From: Stephen Quinney <stephen(dot)quinney(at)computing-services(dot)oxford(dot)ac(dot)uk>
To: Chris Gamache <cgg007(at)yahoo(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Converting integer to binary
Date: 2004-06-11 07:54:02
Message-ID: 20040611075402.GA4887@computing-services.oxford.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Jun 10, 2004 at 05:27:31PM -0500, Bruno Wolff III wrote:
> On Thu, Jun 10, 2004 at 13:24:15 -0700,
> Chris Gamache <cgg007(at)yahoo(dot)com> wrote:
>
> Following up on the cast to bit idea, he could do something like
> casting to bit(32). I don't think there is an easy way to get this
> cast to string, so it may not completely solve his problem, depending
> on what he was going to do with the binary representation. On teh other
> hand, for some things a bit field might be more useful than a string.
>
> area=> select 6::bit(32);
> bit
> ----------------------------------
> 00000000000000000000000000000110
> (1 row)

That would probably work for me in this case as I am interfacing to
postgresql via the Perl DBI layer. With perl reading out that field
would give me a string representation.

Thanks for the tips,

Stephen Quinney

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Benoît BOURNON 2004-06-11 08:16:49 Re: search and replace
Previous Message sad 2004-06-11 07:32:58 casting int to bit