Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ Bit(lib) — Sprite KS.390

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Bit  —  C Library Procedures

NAME

Bit_Set, Bit_Clear, Bit_IsSet, Bit_IsClear, Bit_Copy, Bit_Zero, Bit_FindFirstSet, Bit_FindFirstClear, Bit_Intersect, Bit_Union, Bit_AnySet, Bit_Expand, Bit_Alloc, Bit_Free − bit operations

SYNOPSIS

#include <bit.h>
Bit_Set(bitNum, arrayPtr)
 Bit_Clear(bitNum, arrayPtr)
 Bit_IsSet(bitNum, arrayPtr)
 Bit_IsClear(bitNum, arrayPtr)
 Bit_Copy(numBits, srcArrayPtr, destArrayPtr)
 Bit_Zero(numBits, arrayPtr)
 Bit_FindFirstSet(numBits, arrayPtr)
 Bit_FindFirstClear(numBits, arrayPtr)
 Boolean
Bit_Intersect(numBits, array1Ptr, array2Ptr, destArrayPtr)
 Boolean
Bit_Union(numBits, array1Ptr, array2Ptr, destArrayPtr)
 Boolean
Bit_AnySet(numBits, arrayPtr)
 int ∗
Bit_Expand(newNumBits, oldNumBits, oldArrayPtr)
 Bit_Alloc(numBits, arrayPtr)
 Bit_Free(arrayPtr)

ARGUMENTS

int bitNum   (in) The number in the array of the bit to manipulate. 

int numBits   (in) The number of bits in all the ∗arrayPtr variables passed. 

int ∗arrayPtr   (in,out) The array of bits. 

int ∗srcArrayPtr   (in) The array of bits to be copied. 

int ∗destArrayPtr   (out) The array to which bits are copied. 

int ∗array1Ptr   (in) The first source array in an intersection or union operation. 

int ∗array2Ptr   (in) The second source array in an intersection or union operation. 

int newNumBits   (in) The number of bits the expanded array must hold. 

int oldNumBits   (in) The number of bits in the old array. 

int ∗oldArrayPtr   (in) The bit array that is now too small. 

DESCRIPTION

These procedures manipulate integer arrays of bits.  All the procedures operate on integer arrays and numBits is used to compute the size of ∗arrayPtr. If numBits is not a multiple of the number of bits in an integer, it is rounded up to the nearest multiple. 

Bit_Set sets the bitNum bit in ∗arrayPtr. 
Bit_Clear clears the bitNum bit in ∗arrayPtr. 

The predicates Bit_IsSet and Bit_IsClear test to see if the bitNum bit is set or cleared. 

Bit_Zero clears all bits in ∗arrayPtr. 
Bit_Copy copies ∗srcArrayPtr to ∗destArrayptr. 

Bit_FindFirstSet and Bit_FindFirstClear return the index of the rightmost bit in ∗arrayPtr that is set or cleared. The index begins at 0 and -1 is returned if no set or cleared bit is found. 

Bit_Intersect and Bit_Union find the intersection and union, respectively, of the two bit arrays and stores the result in the third array. They return TRUE if the intersection or union is non-empty. For both functions, if destArrayPtr is NULL, the result is not stored anywhere. 

Bit_AnySet examines the array to see if any of the bits is on, returning TRUE if at least one is set and FALSE otherwise. 

Bit_Alloc and Bit_Free are used to allocate and free bit arrays.  Bit_Alloc creates an array to hold numBits bits and sets arrayPtr to point at it. The array initially has no bits set. Bit_Free deallocates a previously-allocated bit array. 

Bit_Expand takes an existing, dynamically-allocated array, oldArrayPtr, along with its width, oldNumBits, and expands it to contain newNumBits bits, returning a pointer to the expanded array. The array may or may not have moved. If the array was moved, the old array was deallocated at the same time. The new bits are initially all 0. 

KEYWORDS

bit, set, clear, copy, zero

Sprite version 1.0  —  December 31, 1988

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026