pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Gamache <cgg007@yahoo.com>
To: Bruno Wolff III <bruno@wolff.to>
To: Stephen Quinney <stephen.quinney@computing-services.oxford.ac.uk>
Cc: pgsql-sql@postgresql.org
Subject: Re: Converting integer to binary
Date: Thu, 10 Jun 2004 13:24:15 -0700 (PDT)
Message-ID: <20040610202415.89117.qmail@web13804.mail.yahoo.com> (raw)
In-Reply-To: <20040610182756.GA22247@wolff.to>


Once upon a time in PostgreSQL there was a function : bitfromint4 ... Any idea
where it has disappeared to?

You can do

# select B'10101101'::int4;
 int4
------
  173
(1 row)

but you want to go

# select 173::varbit;

which is what bitfromint4 used to do.

CG

--- Bruno Wolff III <bruno@wolff.to> wrote:
> On Thu, Jun 10, 2004 at 14:52:41 +0100,
>   Stephen Quinney <stephen.quinney@computing-services.oxford.ac.uk> wrote:
> > 
> > I have searched around but I cannot see any standard way in PostgreSQL
> > to convert from an integer into a binary representation.
> > 
> > Now I have an algorithm to do it so I could write an SQL function, I
> > guess. If there's a standard way to do it though that would be quite nice.
> 
> There doesn't seem to currently be a function that does this. to_char
> would be the logical place since that is what is used to convert various
> numeric types to strings with a decimal representation.
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster



	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 



view thread (5+ messages)  latest in thread

Message-ID: <20040610202415.89117.qmail@web13804.mail.yahoo.com>
Permalink:  ../20040610202415.89117.qmail@web13804.mail.yahoo.com/
Also on:    postgresql.org/message-id/20040610202415.89117.qmail@web13804.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: cgg007@yahoo.com, bruno@wolff.to, stephen.quinney@computing-services.oxford.ac.uk
  Subject: Re: Converting integer to binary
  In-Reply-To: <20040610202415.89117.qmail@web13804.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox