home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Audio 4.94 - Over 11,000 Files
/
audio-11000.iso
/
amiga
/
midi
/
obrst103.lha
/
OberSuite-1.03
/
SourceCode
/
bits.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-23
|
945b
|
37 lines
/**************************************************************************
* bits.c: Functions for manipulating bit vectors.
* A part of OberSuite for the Commodore Amiga.
*
* Author: Daniel Barrett, barrett@cs.umass.edu.
* Version: 1.0.
* Copyright: None! This program is in the Public Domain.
* Please share it with others.
***************************************************************************/
#include "bits.h"
/* Given a bit vector, turn on the nth bit (counting from 0). */
void FlipOn(BITS bitfield[], int n)
{
bitfield[n/BITFIELD_WIDTH] |= (1 << (n % BITFIELD_WIDTH));
}
/* Given a bit vector, set all of its bits to 0. */
void ClearBitfield(BITS bitfield[])
{
int i;
for (i=0; i<BITFIELD_LENGTH; i++)
bitfield[i] = (BITS)0;
}
/* Given a bit vector, determine whether or not a given bit is on. */
BOOL BitOn(BITS bitfield[], int bit)
{
return(bitfield[bit/BITFIELD_WIDTH] & (1 << (bit % BITFIELD_WIDTH)));
}