varbit functions

From: TJ O'Donnell <tjo(at)acm(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: varbit functions
Date: 2005-04-02 16:53:42
Message-ID: 424ECE16.1040101@acm.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm using bit and bit varying datatypes to store chemical
"fingerprints" and need various functions to operate on
these datatypes. The logical operators (and, or, not)
and the shift operators, as well as length and octet-length
all work fine on bit types. I was hoping for a manual entry
that specifically discusses functions for bit and bit varying,
like the one for dates, strings, etc. Does anyone know of such
a manual entry? I see bits (no pun intended) of info scattered
around. \df helps some too. I'll consider writing such an entry
unless someone can point me to something existing.

So, the functions I need are (at least):

int nbits_set(bit) ;to count # of bits set in the string.
void bit_set(bit, int) ;to set a particular bit in a string.
bool isbit_set(bit) ;to test whether a particular bit is set.

I've already written nbits_set (in c) and could write the others,
but I want to ask if functions like these already exist (and I
just can't find them)? Does anyone have any ideas about how to
use combinations of existing functions (shifts, ands, etc.) to do
these functions? The bit strings I am interested in range from
20 to maybe 1024.

TJ

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2005-04-02 16:57:34 Re: [GENERAL] plPHP in core?
Previous Message Joshua D. Drake 2005-04-02 16:51:19 Re: [GENERAL] plPHP in core?