Index: trunk/psLib/src/pslib_strict.h
===================================================================
--- trunk/psLib/src/pslib_strict.h	(revision 27249)
+++ trunk/psLib/src/pslib_strict.h	(revision 27303)
@@ -102,5 +102,5 @@
 #include "psType.h"
 #include "psArray.h"
-#include "psBitSet.h"
+#include "psBits.h"
 #include "psHash.h"
 #include "psList.h"
Index: trunk/psLib/src/sys/psType.c
===================================================================
--- trunk/psLib/src/sys/psType.c	(revision 27249)
+++ trunk/psLib/src/sys/psType.c	(revision 27303)
@@ -20,5 +20,5 @@
 
 #include "psType.h"
-#include "psBitSet.h"
+#include "psBits.h"
 #include "psFits.h"
 #include "psPixels.h"
@@ -45,6 +45,6 @@
         }
         break;
-    case PS_DATA_BITSET:
-        if (psMemCheckBitSet(ptr)) {
+    case PS_DATA_BITS:
+        if (psMemCheckBits(ptr)) {
             return true;
         }
Index: trunk/psLib/src/sys/psType.h
===================================================================
--- trunk/psLib/src/sys/psType.h	(revision 27249)
+++ trunk/psLib/src/sys/psType.h	(revision 27303)
@@ -107,5 +107,5 @@
     PS_DATA_STRING = 0x10000,          ///< psString (char *)
     PS_DATA_ARRAY,                     ///< psArray
-    PS_DATA_BITSET,                    ///< psBitSet
+    PS_DATA_BITS,                      ///< psBits
     PS_DATA_CUBE,                      ///< psCube
     PS_DATA_FITS,                      ///< psFits
Index: trunk/psLib/src/types/Makefile.am
===================================================================
--- trunk/psLib/src/types/Makefile.am	(revision 27249)
+++ trunk/psLib/src/types/Makefile.am	(revision 27303)
@@ -6,5 +6,5 @@
 libpslibtypes_la_SOURCES = \
 	psArray.c \
-	psBitSet.c \
+	psBits.c \
 	psHash.c \
 	psList.c \
@@ -23,5 +23,5 @@
 pkginclude_HEADERS = \
 	psArray.h \
-	psBitSet.h \
+	psBits.h \
 	psHash.h \
 	psList.h \
Index: trunk/psLib/src/types/psBitSet.c
===================================================================
--- trunk/psLib/src/types/psBitSet.c	(revision 27249)
+++ 	(revision )
@@ -1,303 +1,0 @@
-/** @file  psBitSet.c
- *
- *  @brief Creates an array of bytes of arbitrary length for storing individual bits.
- *
- *  Bit masks are useful tools for toggling various flags and options. This set of functions module provides
- *  a mechanism to create an array of bits of arbitrary length and manipulate them with basic binary
- *  operations. A print function is also provided to display the entire set of bits in binary format as a
- *  string.
- *
- *  @author Ross Harman, MHPCC
- *  @author Robert DeSonia, MHPCC
- *
- *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-08-09 03:30:16 $
- *
- *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <math.h>
-
-#include "psBitSet.h"
-#include "psMemory.h"
-#include "psError.h"
-#include "psAbort.h"
-#include "psString.h"
-#include "psAssert.h"
-
-
-
-enum {
-    UNKNOWN_OP,
-    AND_OP,
-    OR_OP,
-    XOR_OP,
-    NOT_OP
-};
-
-static void bitSetFree(psBitSet* inBitSet);
-
-/** Private function to create a mask.
- *
- *  Creates an eight bit mask with the given bit set. All other bits in the byte are zero. The input bit uses
- *  zero-based indexing, and is the cumulitive index within the array, not the localized byte's bit position.
- *
- *  @return  char*: Pointer to byte in which bit is contained.
- */
-PS_ATTR_PURE static char mask(psS32 bit)
-{
-    char mask = (char)0x01;
-
-    // Ignore splint warning about negative bit shifts
-    /* @i@ */
-    mask = mask << (bit % 8);
-
-    return mask;
-}
-
-static void bitSetFree(psBitSet* inBitSet)
-{
-    psFree(inBitSet->bits);
-}
-
-bool psMemCheckBitSet(psPtr ptr)
-{
-    PS_ASSERT_PTR(ptr, false);
-    return ( psMemGetDeallocator(ptr) == (psFreeFunc)bitSetFree );
-}
-
-
-psBitSet* p_psBitSetAlloc(const char *file,
-                          unsigned int lineno,
-                          const char *func,
-                          long nalloc)
-{
-    if (nalloc < 0) {
-        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                _("The number of bit in a psBitSet (%ld) must be greater than zero."),
-                nalloc);
-        return NULL;
-    }
-
-    psS32 numBytes = 0;
-    psBitSet* newObj = NULL;
-
-    numBytes = ceil(nalloc / 8.0);
-    newObj = p_psAlloc(file, lineno, func, sizeof(psBitSet));
-    psMemSetDeallocator(newObj, (psFreeFunc) bitSetFree);
-    newObj->n = numBytes;
-
-    // Ignore splint warning about releasing pointer members, since they've not been allocated yet
-    /* @i@ */
-    newObj->bits = psAlloc(sizeof(char) * numBytes);
-
-    memset(newObj->bits, 0, numBytes);
-
-    return newObj;
-}
-
-
-bool psBitSetSet(psBitSet* bitSet,
-                      long bit)
-{
-    unsigned char *byte = NULL;
-
-    if (bitSet == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("Can not operate on a NULL psBitSet."));
-        return false;
-    } else if ( (bit < 0) ||
-                (bit > bitSet->n * 8 - 1) ) {
-        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                _("The specified bit position (%ld) is invalid.  Position must be between 0 and %ld."),
-                bit, bitSet->n * 8 - 1);
-        return false;
-    }
-    // Variable byte is the byte in the array that contains the bit to be set
-    byte = bitSet->bits + bit / 8;
-    *byte |= mask(bit);
-
-    return true;
-}
-
-bool psBitSetClear(psBitSet* bitSet,
-                        long bit)
-{
-    unsigned char *byte = NULL;
-
-    if (bitSet == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("Can not operate on a NULL psBitSet."));
-        return false;
-    } else if ( (bit < 0) ||
-                (bit > bitSet->n * 8 - 1) ) {
-        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                _("The specified bit position (%ld) is invalid.  Position must be between 0 and %ld."),
-                bit, bitSet->n * 8 - 1);
-        return false;
-    }
-    // Variable byte is the byte in the array that contains the bit to be set
-    byte = bitSet->bits + bit / 8;
-    *byte &= ! mask(bit);
-
-    return true;
-}
-
-bool psBitSetTest(const psBitSet* bitSet,
-                  long bit)
-{
-    unsigned char *byte = NULL;
-
-    if (bitSet == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("Can not operate on a NULL psBitSet."));
-        return false;
-    } else if ( (bit < 0) ||
-                (bit > bitSet->n * 8 - 1) ) {
-        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                _("The specified bit position (%ld) is invalid.  Position must be between 0 and %ld."),
-                bit,bitSet->n * 8 - 1);
-        return false;
-    }
-
-    // Variable byte is the byte in the array that contains the bit to be tested
-    byte = bitSet->bits + bit / 8;
-    return ((*byte & mask(bit)) != 0);
-}
-
-psBitSet* psBitSetOp(psBitSet* outBitSet,
-                     const psBitSet* inBitSet1,
-                     const char *operator,
-                     const psBitSet* inBitSet2)
-{
-    if (inBitSet1 == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("First psBitSet operand can not be NULL."));
-        psFree(outBitSet);
-        return NULL;
-    }
-    if (operator == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("Specified operator is NULL.  Must specify desired operator."));
-        psFree(outBitSet);
-        return NULL;
-    }
-    psS32 i = 0;
-    psS32 n = 0;
-    unsigned char* outBits = NULL;
-    unsigned char* inBits1 = NULL;
-    unsigned char* inBits2 = NULL;
-    psS32 op = UNKNOWN_OP;
-
-    inBits1 = inBitSet1->bits;
-
-
-    // parse the operator
-    if (strcmp(operator,"AND")==0) {
-        op = AND_OP;
-    } else if (strcmp(operator,"OR")==0) {
-        op = OR_OP;
-    } else if (strcmp(operator,"XOR")==0) {
-        op = XOR_OP;
-    } else if (strcmp(operator,"NOT")==0) {
-        op = NOT_OP;
-    } else {
-        psFree(outBitSet);
-        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                _("Specified operator, %s, is invalid.  Valid operators are AND, OR, and XOR."),
-                operator);
-        return NULL;
-    }
-
-    if (op != NOT_OP) {
-        if (inBitSet2 == NULL) {
-            psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                    _("Second psBitSet operand can not be NULL."));
-            psFree(outBitSet);
-            return NULL;
-        }
-
-        if (inBitSet1->n != inBitSet2->n) {
-            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
-                    _("The psBitSet operand must be the same size."));
-            psFree(outBitSet);
-            return NULL;
-        }
-        inBits2 = inBitSet2->bits;
-    }
-
-    if (outBitSet == NULL) {
-        outBitSet = psBitSetAlloc(inBitSet1->n*8);
-    } else if (outBitSet->n != inBitSet1->n) {
-        outBitSet->n = inBitSet1->n;
-        outBitSet->bits = psRealloc(outBitSet->bits, inBitSet1->n);
-    }
-
-    n = outBitSet->n;
-    outBits = outBitSet->bits;
-
-    switch (op) {
-    case AND_OP:
-        for (i = 0; i < n; i++) {
-            outBits[i] = inBits1[i] & inBits2[i];
-        }
-        break;
-    case OR_OP:
-        for (i = 0; i < n; i++) {
-            outBits[i] = inBits1[i] | inBits2[i];
-        }
-        break;
-    case XOR_OP:
-        for (i = 0; i < n; i++) {
-            outBits[i] = inBits1[i] ^ inBits2[i];
-        }
-        break;
-    case NOT_OP:
-    default:
-        for (i = 0; i < n; i++) {
-            outBits[i] = ~inBits1[i];
-        }
-        break;
-    }
-
-    return outBitSet;
-}
-
-psBitSet* psBitSetNot(psBitSet* outBitSet,
-                      const psBitSet* inBitSet)
-{
-    if (inBitSet == NULL) {
-        psError(PS_ERR_BAD_PARAMETER_NULL, true,
-                _("Operand can not be NULL."));
-        psFree(outBitSet);
-        return NULL;
-    }
-
-    outBitSet = psBitSetOp(outBitSet,inBitSet,"NOT",NULL);
-
-    return outBitSet;
-}
-
-psString psBitSetToString(const psBitSet* bitSet)
-{
-    PS_ASSERT_PTR_NON_NULL(bitSet, NULL);
-    psS32 i = 0;
-    psS32 numBits = bitSet->n * 8;
-    //    char *outString = psAlloc((size_t) numBits + 1);
-    psString outString = psStringAlloc(numBits + 1);
-
-    for (i = 0; i < numBits; i++) {
-        outString[numBits - i - 1] = psBitSetTest(bitSet, i) ? '1' : '0';
-    }
-
-    outString[numBits] = 0;
-
-    return outString;
-}
Index: trunk/psLib/src/types/psBitSet.h
===================================================================
--- trunk/psLib/src/types/psBitSet.h	(revision 27249)
+++ 	(revision )
@@ -1,175 +1,0 @@
-/** @file  psBitSet.h
- *
- *  @brief Creates an array of bytes of arbitrary length for storing individual bits.
- *
- *  Bit masks are useful tools for toggling various flags and options. This set of functions module provides
- *  a mechanism to create an array of bits of arbitrary length and manipulate them with basic binary
- *  operations. A print function is also provided to display the entire set of bits in binary format as a
- *  string.
- *
- *  @author PAP, EAM, IfA
- *  @author Ross Harman, MHPCC
- *
- *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-08-14 03:18:41 $
- *
- *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
- */
-
-#ifndef PSBITSET_H
-#define PSBITSET_H
-
-#include "psType.h"
-#include "psMutex.h"
-
-/// @addtogroup DataContainer Data Containers
-/// @{
-
-/******************************************************************************/
-/*  TYPE DEFINITIONS                                                          */
-/******************************************************************************/
-
-/** Struct containing array of bytes to hold bit data and corresponding array length.
- *
- *  The bits in the struct are assembled in as an array of bytes with eight bits per
- *  byte. The bits are arranged with the LSB in first (right most) position of the
- *  first array element.
- */
-typedef struct
-{
-    long n;                            ///< Number of bytes in the array
-    psU8 *bits;                        ///< Aray of bytes holding bits
-    psMutex lock;                       ///< Optional lock for thread safety
-}
-psBitSet;
-
-/*****************************************************************************/
-/* FUNCTION PROTOTYPES                                                       */
-/*****************************************************************************/
-
-/** Checks the type of a particular pointer.
- *
- *  Uses the appropriate deallocation function in psMemBlock to check the ptr
- *  datatype.
- *
- *  @return bool:     True if the pointer matches a psBitSet structure, false otherwise.
- */
-bool psMemCheckBitSet(
-    psPtr ptr                          ///< the pointer whose type to check
-);
-
-
-/** Allocate a psBitSet.
- *
- *  Create a psBitSet with the number of bits specified by the user. All bits
- *  are set to zero upon allocation.
- *
- *  @return  psBitSet* : Pointer to struct containing array of bits and size of array.
- */
-#ifdef DOXYGEN
-psBitSet* psBitSetAlloc(
-    long nalloc                        ///< Number of bits in psBitSet array
-);
-#else // ifdef DOXYGEN
-psBitSet* p_psBitSetAlloc(
-    const char *file,                   ///< File of caller
-    unsigned int lineno,                ///< Line number of caller
-    const char *func,                   ///< Function name of caller
-    long nalloc                        ///< Number of bits in psBitSet array
-) PS_ATTR_MALLOC;
-#define psBitSetAlloc(nalloc) \
-      p_psBitSetAlloc(__FILE__, __LINE__, __func__, nalloc)
-#endif // ifdef DOXYGEN
-
-
-
-
-/** Set a bit.
- *
- *  Sets a bit at a given bit location. The bit is set based on a zero index
- *  with the first bit set in the zero bit slot of the zero element of the byte
- *  array. As an example, setting bit 3 in an array with two elements would
- *  result in an psBitSet that looks like 00000000 00001000.
- *
- *  @return  bool : Successful operation?
- */
-bool psBitSetSet(
-    psBitSet* bitSet,                  ///< Pointer to psBitSet to be set.
-    long bit                           ///< Bit to be set.
-);
-
-
-/** Clear a bit.
- *
- *  Clear a bit at a given bit location. The bit is cleared based on a zero
- *  index with the first bit set in the zero bit slot of the zero element of
- *  the byte array.
- *
- *  @return  bool : Successful operation?
- */
-bool psBitSetClear(
-    psBitSet* bitSet,                  ///< Pointer to psBitSet to be cleared.
-    long bit                           ///< Bit to be cleared.
-);
-
-
-/** Test the value of a bit.
- *
- *  Prints the value of a bit at a given bit location, either one or zero. The
- *  resulting bit is based on a zero index format with the first bit set in the
- *  zero bit slot of the zero element of the byte array.  As an example,
- *  testing bit 3 in a psBitSet with two bytes that looks like 00000000
- *  00001000 would return a value of one, since that is the value that was set.
- *
- *  @return  bool:      True if successful, otherwise false
- */
-bool psBitSetTest(
-    const psBitSet* bitSet,            ///< Pointer psBitSet to be tested.
-    long bit                           ///< Bit to be tested.
-);
-
-
-/** Perform a binary operation on two psBitSets
- *
- *  Perform an AND, OR, or XOR on two psBitSets. If the BitMasks are not the
- *  same size, the operation will not be performed and an error message will be
- *  logged.
- *
- *  @return  psBitSet* : Pointer to struct containing result of binary operation.
- */
-psBitSet* psBitSetOp(
-    psBitSet* outBitSet,               ///< Resulting psBitSet from binary operation
-    const psBitSet* inBitSet1,         ///< First psBitSet on which to operate
-    const char *operator,              ///< Bit operation
-    const psBitSet* inBitSet2          ///< Second psBitSet on which to operate
-);
-
-
-/** Perform a not operation on a psBitSet
- *
- *  Toggles bits in a psBitset. All zero bits are set to one and all one bits
- *  are set to zero.
- *
- *  @return  psBitSet* : Pointer to struct containing result of operation.
- */
-psBitSet* psBitSetNot(
-    psBitSet* outBitSet,               ///< Resulting psBitSet from operation
-    const psBitSet* inBitSet           ///< Input psBitSet
-);
-
-
-/** Convert the psBitSet to a string of ones and zeros.
- *
- *  Converts the contents of a psBitSet to a string representation of its
- *  binary form of ones and zeros. The LSB is the right-most chracter. Each set
- *  of eight characters represents one byte.
- *
- *  @return  psString:      Pointer to character array containing string data.
- */
-psString psBitSetToString(
-    const psBitSet* bitSet             ///< psBitSet to convert
-);
-
-
-/// @}
-#endif // #ifndef PSBITSET_H
Index: trunk/psLib/src/types/psBits.c
===================================================================
--- trunk/psLib/src/types/psBits.c	(revision 27303)
+++ trunk/psLib/src/types/psBits.c	(revision 27303)
@@ -0,0 +1,219 @@
+/** @file  psBits.c
+ *
+ *  @brief Creates an array of bytes of arbitrary length for storing individual bits.
+ *
+ *  Bit masks are useful tools for toggling various flags and options. This set of functions module provides
+ *  a mechanism to create an array of bits of arbitrary length and manipulate them with basic binary
+ *  operations. A print function is also provided to display the entire set of bits in binary format as a
+ *  string.
+ *
+ *  @author Ross Harman, MHPCC
+ *  @author Robert DeSonia, MHPCC
+ *
+ *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-08-09 03:30:16 $
+ *
+ *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+
+#include "psBits.h"
+#include "psMemory.h"
+#include "psError.h"
+#include "psAbort.h"
+#include "psString.h"
+#include "psAssert.h"
+
+
+static void bitsFree(psBits *inBits);
+
+/** Private function to create a mask.
+ *
+ *  Creates an eight bit mask with the given bit set. All other bits in the byte are zero. The input bit uses
+ *  zero-based indexing, and is the cumulitive index within the array, not the localized byte's bit position.
+ *
+ *  @return  char*: Pointer to byte in which bit is contained.
+ */
+PS_ATTR_PURE static inline char mask(long bit)
+{
+    psAssert(bit < 8, "Bad bit: %ld", bit);
+    return (char)0x01 << (bit % 8);
+}
+
+// Return the byte with the bit of interest
+static inline psU8 *bitsGetByte(const psBits *bits, long bit)
+{
+    return bits->bits + bit / 8;
+}
+
+
+static void bitsFree(psBits *inBits)
+{
+    psFree(inBits->bits);
+}
+
+bool psMemCheckBits(psPtr ptr)
+{
+    PS_ASSERT_PTR(ptr, false);
+    return (psMemGetDeallocator(ptr) == (psFreeFunc)bitsFree);
+}
+
+
+psBits *p_psBitsAlloc(const char *file, unsigned int lineno, const char *func, long nalloc)
+{
+    psAssert(nalloc >= 0, "The number of bits in a psBits (%ld) must be greater than zero.", nalloc);
+
+    int numBytes = ceil((float)nalloc / 8.0); // Number of bytes to use
+    psBits *bits = p_psAlloc(file, lineno, func, sizeof(psBits));
+    psMemSetDeallocator(bits, (psFreeFunc)bitsFree);
+    bits->n = nalloc;
+
+    bits->bits = p_psAlloc(file, lineno, func, numBytes);
+    memset(bits->bits, 0, numBytes);
+
+    return bits;
+}
+
+
+bool psBitsSet(psBits *bits, long bit)
+{
+    PS_ASSERT_BITS_NON_NULL(bits, false);
+    PS_ASSERT_BITS_VALID_BIT(bits, bit, false);
+
+    psU8 *byte = bitsGetByte(bits, bit);  // Byte with the bit of interest
+    *byte |= mask(bit);
+
+    return true;
+}
+
+bool psBitsClear(psBits *bits, long bit)
+{
+    PS_ASSERT_BITS_NON_NULL(bits, false);
+    PS_ASSERT_BITS_VALID_BIT(bits, bit, false);
+
+    psU8 *byte = bitsGetByte(bits, bit);  // Byte with the bit of interest
+    *byte &= !mask(bit);
+
+    return true;
+}
+
+
+bool psBitsTest(const psBits *bits, long bit)
+{
+    // XXX These errors probably cannot be caught
+    PS_ASSERT_BITS_NON_NULL(bits, false);
+    PS_ASSERT_BITS_VALID_BIT(bits, bit, false);
+
+    psU8 *byte = bitsGetByte(bits, bit);  // Byte with the bit of interest
+    return ((*byte & mask(bit)) != 0);
+}
+
+psBits *psBitsOp(psBits *outBits, const psBits *bits1, const char *operator, const psBits *bits2)
+{
+    PS_ASSERT_BITS_NON_NULL(bits1, NULL);
+    PS_ASSERT_STRING_NON_EMPTY(operator, NULL);
+
+    enum {
+        UNKNOWN_OP,
+        AND_OP,
+        OR_OP,
+        XOR_OP,
+        NOT_OP
+    } op = UNKNOWN_OP;
+
+    // Parse the operator
+    if (strcmp(operator, "AND") == 0) {
+        op = AND_OP;
+    } else if (strcmp(operator, "OR") == 0) {
+        op = OR_OP;
+    } else if (strcmp(operator, "XOR") == 0) {
+        op = XOR_OP;
+    } else if (strcmp(operator, "NOT") == 0) {
+        op = NOT_OP;
+    } else {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                _("Specified operator, %s, is invalid.  Valid operators are AND, OR, XOR, NOT."),
+                operator);
+        return NULL;
+    }
+
+    if (op != NOT_OP) {
+        PS_ASSERT_BITS_NON_NULL(bits2, false);
+        if (bits1->n != bits2->n) {
+            psError(PS_ERR_BAD_PARAMETER_SIZE, true,
+                    "The psBits operands must be the same size: %ld vs %ld",
+                    bits1->n, bits2->n);
+            return NULL;
+        }
+    }
+
+    int numBits = bits1->n;                   // Number of bits
+    int numBytes = ceil((float)numBits / 8.0); // Number of bytes
+
+    if (!outBits) {
+        outBits = psBitsAlloc(numBits);
+    } else if (outBits->n != numBits) {
+        outBits->n = numBits;
+        outBits->bits = psRealloc(outBits->bits, numBytes);
+    }
+
+    psU8 *in1 = bits1->bits;                  // Bits for input 1
+    psU8 *in2 = (op == NOT_OP) ? NULL : bits2->bits; // Bits for input 2
+    psU8 *out = outBits->bits;                       // Bits for output
+
+    switch (op) {
+    case AND_OP:
+        for (int i = 0; i < numBytes; i++) {
+            out[i] = in1[i] & in2[i];
+        }
+        break;
+    case OR_OP:
+        for (int i = 0; i < numBytes; i++) {
+            out[i] = in1[i] | in2[i];
+        }
+        break;
+    case XOR_OP:
+        for (int i = 0; i < numBytes; i++) {
+            out[i] = in1[i] ^ in2[i];
+        }
+        break;
+    case NOT_OP:
+    default:
+        for (int i = 0; i < numBytes; i++) {
+            out[i] = ~in1[i];
+        }
+        break;
+    }
+
+    return outBits;
+}
+
+psBits *psBitsNot(psBits *outBits, const psBits *inBits)
+{
+    return psBitsOp(outBits, inBits, "NOT", NULL);
+}
+
+psString psBitsToString(const psBits *bits)
+{
+    PS_ASSERT_BITS_NON_NULL(bits, NULL);
+
+    psS32 numBits = bits->n;
+    psString string = psStringAlloc(numBits + 1);
+
+    char *out = &string[numBits];
+    *out = '\0';
+    out--;
+    for (long i = 0; i < numBits; i++, out--) {
+        *out = psBitsTest(bits, i) ? '1' : '0';
+    }
+
+    return string;
+}
Index: trunk/psLib/src/types/psBits.h
===================================================================
--- trunk/psLib/src/types/psBits.h	(revision 27303)
+++ trunk/psLib/src/types/psBits.h	(revision 27303)
@@ -0,0 +1,191 @@
+/** @file  psBits.h
+ *
+ *  @brief Creates an array of bytes of arbitrary length for storing individual bits.
+ *
+ *  Bit masks are useful tools for toggling various flags and options. This set of functions module provides
+ *  a mechanism to create an array of bits of arbitrary length and manipulate them with basic binary
+ *  operations. A print function is also provided to display the entire set of bits in binary format as a
+ *  string.
+ *
+ *  @author PAP, EAM, IfA
+ *  @author Ross Harman, MHPCC
+ *
+ *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2008-08-14 03:18:41 $
+ *
+ *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
+ */
+
+#ifndef PSBITS_H
+#define PSBITS_H
+
+#include "psType.h"
+#include "psMutex.h"
+
+/// @addtogroup DataContainer Data Containers
+/// @{
+
+/******************************************************************************/
+/*  TYPE DEFINITIONS                                                          */
+/******************************************************************************/
+
+/** Struct containing array of bytes to hold bit data and corresponding array length.
+ *
+ *  The bits in the struct are assembled in as an array of bytes with eight bits per
+ *  byte. The bits are arranged with the LSB in first (right most) position of the
+ *  first array element.
+ */
+typedef struct
+{
+    long n;                             ///< Number of bits in the array
+    psU8 *bits;                         ///< Aray of bytes holding bits
+    psMutex lock;                       ///< Optional lock for thread safety
+} psBits;
+
+/*****************************************************************************/
+/* FUNCTION PROTOTYPES                                                       */
+/*****************************************************************************/
+
+/** Checks the type of a particular pointer.
+ *
+ *  Uses the appropriate deallocation function in psMemBlock to check the ptr
+ *  datatype.
+ *
+ *  @return bool:     True if the pointer matches a psBits structure, false otherwise.
+ */
+bool psMemCheckBits(
+    psPtr ptr                          ///< the pointer whose type to check
+);
+
+
+/** Allocate a psBits.
+ *
+ *  Create a psBits with the number of bits specified by the user. All bits
+ *  are set to zero upon allocation.
+ *
+ *  @return  psBits* : Pointer to struct containing array of bits and size of array.
+ */
+#ifdef DOXYGEN
+psBits* psBitsAlloc(
+    long nalloc                        ///< Number of bits in psBits array
+);
+#else // ifdef DOXYGEN
+psBits* p_psBitsAlloc(
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func,                   ///< Function name of caller
+    long nalloc                        ///< Number of bits in psBits array
+) PS_ATTR_MALLOC;
+#define psBitsAlloc(nalloc) \
+      p_psBitsAlloc(__FILE__, __LINE__, __func__, nalloc)
+#endif // ifdef DOXYGEN
+
+
+
+
+/** Set a bit.
+ *
+ *  Sets a bit at a given bit location. The bit is set based on a zero index
+ *  with the first bit set in the zero bit slot of the zero element of the byte
+ *  array. As an example, setting bit 3 in an array with two elements would
+ *  result in an psBits that looks like 00000000 00001000.
+ *
+ *  @return  bool : Successful operation?
+ */
+bool psBitsSet(
+    psBits* bits,                  ///< Pointer to psBits to be set.
+    long bit                           ///< Bit to be set.
+);
+
+
+/** Clear a bit.
+ *
+ *  Clear a bit at a given bit location. The bit is cleared based on a zero
+ *  index with the first bit set in the zero bit slot of the zero element of
+ *  the byte array.
+ *
+ *  @return  bool : Successful operation?
+ */
+bool psBitsClear(
+    psBits* bits,                  ///< Pointer to psBits to be cleared.
+    long bit                           ///< Bit to be cleared.
+);
+
+
+/** Test the value of a bit.
+ *
+ *  Prints the value of a bit at a given bit location, either one or zero. The
+ *  resulting bit is based on a zero index format with the first bit set in the
+ *  zero bit slot of the zero element of the byte array.  As an example,
+ *  testing bit 3 in a psBits with two bytes that looks like 00000000
+ *  00001000 would return a value of one, since that is the value that was set.
+ *
+ *  @return  bool:      True if successful, otherwise false
+ */
+bool psBitsTest(
+    const psBits* bits,            ///< Pointer psBits to be tested.
+    long bit                           ///< Bit to be tested.
+);
+
+
+/** Perform a binary operation on two psBitss
+ *
+ *  Perform an AND, OR, or XOR on two psBitss. If the BitMasks are not the
+ *  same size, the operation will not be performed and an error message will be
+ *  logged.
+ *
+ *  @return  psBits* : Pointer to struct containing result of binary operation.
+ */
+psBits* psBitsOp(
+    psBits* outBits,               ///< Resulting psBits from binary operation
+    const psBits* inBits1,         ///< First psBits on which to operate
+    const char *operator,              ///< Bit operation
+    const psBits* inBits2          ///< Second psBits on which to operate
+);
+
+
+/** Perform a not operation on a psBits
+ *
+ *  Toggles bits in a psBits. All zero bits are set to one and all one bits
+ *  are set to zero.
+ *
+ *  @return  psBits* : Pointer to struct containing result of operation.
+ */
+psBits* psBitsNot(
+    psBits* outBits,               ///< Resulting psBits from operation
+    const psBits* inBits           ///< Input psBits
+);
+
+
+/** Convert the psBits to a string of ones and zeros.
+ *
+ *  Converts the contents of a psBits to a string representation of its
+ *  binary form of ones and zeros. The LSB is the right-most chracter. Each set
+ *  of eight characters represents one byte.
+ *
+ *  @return  psString:      Pointer to character array containing string data.
+ */
+psString psBitsToString(
+    const psBits* bits             ///< psBits to convert
+);
+
+#define PS_ASSERT_BITS_NON_NULL(NAME, RVAL) \
+if ((NAME) == NULL || (NAME)->bits == NULL || (NAME)->n < 0) { \
+    psError(PS_ERR_BAD_PARAMETER_NULL, true, \
+            "Unallowable operation: psBits %s or its data is NULL.", \
+            #NAME); \
+    return RVAL; \
+} \
+
+#define PS_ASSERT_BITS_VALID_BIT(NAME, BIT, RVAL)              \
+    if (BIT < 0 || BIT >= (NAME)->n) {     \
+    psError(PS_ERR_BAD_PARAMETER_VALUE, true, \
+            "Unallowable operation: psBits %s or its data is NULL.", \
+            #NAME); \
+    return RVAL; \
+} \
+
+
+
+/// @}
+#endif // #ifndef PSBITS_H
Index: trunk/psLib/src/types/psMetadata.c
===================================================================
--- trunk/psLib/src/types/psMetadata.c	(revision 27249)
+++ trunk/psLib/src/types/psMetadata.c	(revision 27303)
@@ -280,5 +280,5 @@
     }
     case     PS_DATA_ARRAY:                     // psArray
-    case     PS_DATA_BITSET:                    // psBitSet
+    case     PS_DATA_BITS:                      // psBits
     case     PS_DATA_CUBE:                      // psCube
     case     PS_DATA_FITS:                      // psFits
Index: trunk/psLib/test/types/Makefile.am
===================================================================
--- trunk/psLib/test/types/Makefile.am	(revision 27249)
+++ trunk/psLib/test/types/Makefile.am	(revision 27303)
@@ -29,5 +29,5 @@
 	tap_psPixels_all \
 	tap_psHash_all \
-	tap_psBitSet_all \
+	tap_psBits_all \
 	tap_psList_all \
 	tap_psLookupTable_all \
Index: trunk/psLib/test/types/tap_psBitSet_all.c
===================================================================
--- trunk/psLib/test/types/tap_psBitSet_all.c	(revision 27249)
+++ 	(revision )
@@ -1,279 +1,0 @@
-/**
- *  C Implementation: tap_psBitSet_all
- *
- * Description:  Tests for psBitSetAlloc, psBitSetSet, psMemCheckBitSet, psBitSetClear,
- *               psBitSetTest, psBitSetOp, psBitSetNot, psBitSetToString
- *
- * Author: dRob <David.Robbins@mhpcc.hpc.mil>, (C) 2006
- *
- * Copyright: See COPYING file that comes with this distribution
- *
- */
-#include <pslib.h>
-#include <string.h>
-#include "tap.h"
-#include "pstap.h"
-
-
-int main(void)
-{
-    psLogSetFormat("HLNM");
-    psLogSetLevel(PS_LOG_INFO);
-    plan_tests(31);
-
-
-    // testBitSetBasics()
-    {
-        psMemId id = psMemGetId();
-        psBitSet *noBits = NULL;
-        psBitSet *bs = NULL;
-
-        //Return NULL for attempt to Allocate BitSet of negative size.
-        {
-            noBits = psBitSetAlloc(-1);
-            ok( noBits == NULL,
-                "psBitSetAlloc:         return NULL for negative BitSet-size input.");
-        }
-        //Return properly allocated 0-size psBitSet
-        {
-            bs = psBitSetAlloc(0);
-            ok( bs != NULL && psMemCheckBitSet(bs) && bs->n == 0,
-                "psBitSetAlloc:         return properly allocated psBitSet.");
-        }
-        //Return properly allocated psBitSet
-        {
-            psFree(bs);
-            bs = psBitSetAlloc(8);
-            ok( bs != NULL && psMemCheckBitSet(bs) && bs->n == 1,
-                "psBitSetAlloc:         return properly allocated psBitSet.");
-        }
-        //Make sure psMemCheckBitSet works correctly - return false
-        if (0) {
-            int j = 2;
-            ok( !psMemCheckBitSet(&j),
-                "psMemCheckBitSet:      return false for non-BitSet input.");
-        }
-
-        //BitSetSet Tests
-        //Return FALSE for NULL input psBitSet
-        {
-            bool rc = psBitSetSet(NULL, 0);
-            ok(rc == false,
-                "psBitSetSet:           return FALSE for NULL BitSet input.");
-        }
-        //Return FALSE for negative bit input
-        {
-            bool rc = psBitSetSet(bs, -1);
-            ok( rc == false,
-                "psBitSetSet:           return TRUE for negative bits input.");
-            noBits = NULL;
-        }
-        //Return FALSE for out-of-range bits
-        {
-            psFree(bs);
-            bs = psBitSetAlloc(8);
-            bool rc = psBitSetSet(bs, 8);
-            ok( rc == false,
-                "psBitSetSet:           return TRUE for out-of-range bits input.");
-            noBits = NULL;
-        }
-
-        //Return set BitSet for valid inputs
-        {
-            psBitSetSet(bs, 2);
-            ok( bs->bits[0] == 4,
-                "psBitSetSet:           return properly set BitSet for valid inputs.");
-        }
-
-        //BitSetClear Tests
-        //Return FALSE for NULL input psBitSet
-        {
-            bool rc = psBitSetClear(noBits, 0);
-            ok( rc == false,
-                "psBitSetClear:         return FALSE for NULL BitSet input.");
-        }
-        //Return FALSE for negative bit input
-        {
-            bool rc = psBitSetClear(bs, -1);
-            ok( rc == false,
-                "psBitSetClear:        return TRUE for negative bits input.");
-            noBits = NULL;
-        }
-        //Return FALSE for out-of-range bits
-        {
-            bool rc = psBitSetClear(bs, 8);
-            ok( rc == false,
-                "psBitSetClear:        return FALSE for out-of-range bits input.");
-            noBits = NULL;
-        }
-
-        //Return cleared BitSet for valid inputs
-        {
-            psBitSetClear(bs, 2);
-            ok( bs->bits[0] == 0,
-                "psBitSetClear:        return properly cleared BitSet for valid inputs.");
-        }
-
-        //BitSetTest Tests
-        //Return false for NULL input psBitSet
-        {
-            ok( !psBitSetTest(noBits, 0),
-                "psBitSetTest:         return false for NULL BitSet input.");
-        }
-        //Return false for negative bit input
-        {
-            ok( !psBitSetTest(bs, -1),
-                "psBitSetTest:         return false for negative bits input.");
-        }
-        //Return false for out-of-range bits
-        {
-            ok( !psBitSetTest(bs, 8),
-                "psBitSetTest:         return false for out-of-range bits input.");
-        }
-        //Return false for non-matching bit in BitSet
-        {
-            ok( !psBitSetTest(bs, 2),
-                "psBitSetTest:         return false for non-matching bit in BitSet.");
-        }
-        //Return false for non-matching bit in BitSet
-        {
-            psBitSetSet(bs, 2);
-            ok( psBitSetTest(bs, 2),
-                "psBitSetTest:         return true for matching bit in BitSet.");
-        }
-
-        psFree(bs);
-        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
-    }
-
-
-    // testBitSetOps()
-    {
-        psMemId id = psMemGetId();
-        psBitSet *noBits = NULL;
-        psBitSet *bs = NULL;
-        bs = psBitSetAlloc(8);
-        psBitSetSet(bs, 2);  // 0000 0100 == 4
-        psBitSetSet(bs, 3);  // 0000 1100 == 12
-        psBitSetSet(bs, 4);  // 0001 1100 == 28
-        psBitSetSet(bs, 5);  // 0011 1100 == 60
-        psBitSetSet(bs, 6);  // 0111 1100 == 124
-        psBitSetSet(bs, 7);  // 1111 1100 == 252
-        psBitSet *out = NULL;
-
-        //psBitSetNot Tests
-        //Return NULL for NULL BitSet input
-        {
-            out = psBitSetNot(out, noBits);
-            ok( out == NULL,
-                "psBitSetNot:          return NULL for NULL BitSet input.");
-        }
-        //Return correct BitSet for valid BitSet input
-        {
-            out = psBitSetNot(out, bs);  //bs = 1111 1100  so out should = 0000 0011 = 3
-            ok( out->bits[0] == 3,
-                "psBitSetNot:          return correct BitSet for valid BitSet input.");
-        }
-
-        //psBitSetOp Tests   out = psBitSetOp(out, bs1, "op", bs2);
-        //Return NULL for NULL BitSet input
-        {
-            psFree(out);
-            out = NULL;
-            out = psBitSetOp(out, noBits, "op", noBits);
-            ok( out == NULL,
-                "psBitSetOp:           return NULL for NULL BitSet input.");
-        }
-        //Return NULL for NULL operator input
-        {
-            out = psBitSetOp(out, bs, NULL, noBits);
-            ok( out == NULL,
-                "psBitSetOp:           return NULL for NULL operator input.");
-        }
-        //Return NULL for invalid operator input
-        {
-            out = psBitSetOp(out, bs, "XAND", noBits);
-            ok( out == NULL,
-                "psBitSetOp:           return NULL for invalid operator input.");
-        }
-        //Return NULL for AND operator with NULL second BitSet input
-        {
-            out = psBitSetOp(out, bs, "AND", noBits);
-            ok( out == NULL,
-                "psBitSetOp:           return NULL for AND operator with NULL second BitSet input.");
-        }
-        //Return NULL for AND operator with BitSet inputs of differing size.
-        psBitSet *bs2 = psBitSetAlloc(16);
-        {
-            out = psBitSetOp(out, bs, "AND", bs2);
-            ok( out == NULL,
-                "psBitSetOp:           return NULL for AND operator with BitSet inputs of"
-                " differing size.");
-        }
-        psFree(bs);
-        bs = psBitSetAlloc(16);
-        psBitSetSet(bs, 1);     // 0000 0010 == 2
-        psBitSetSet(bs2, 2);   // 0000 0100 == 4
-        //Return correct psBitSet output for valid inputs with AND operator
-        {
-            out = psBitSetOp(out, bs, "AND", bs2);
-            ok( out->bits[0] == 0,
-                "psBitSetOp:           return correct psBitSet output for valid inputs"
-                " with AND operator.");
-        }
-        //Return correct psBitSet output for valid inputs with OR operator
-        {
-            out = psBitSetOp(out, bs, "OR", bs2);
-            ok( out->bits[0] == 6,
-                "psBitSetOp:           return correct psBitSet output for valid inputs"
-                " with OR operator.");
-        }
-        //Return correct psBitSet output for valid inputs with XOR operator
-        psBitSetSet(bs2, 1);     // 0000 0110 == 6
-        {
-            out = psBitSetOp(out, bs, "XOR", bs2);
-            ok( out->bits[0] == 4,
-                "psBitSetOp:           return correct psBitSet output for valid inputs"
-                " with XOR operator.");
-        }
-        //Return correct psBitSet output for valid inputs with NOT operator
-        {
-            psFree(out);
-            out = psBitSetAlloc(0);
-            psBitSetSet(bs, 2);  // 0000 0110 == 4
-            psBitSetSet(bs, 3);  // 0000 1110 == 12
-            psBitSetSet(bs, 4);  // 0001 1110 == 28
-            psBitSetSet(bs, 5);  // 0011 1110 == 60
-            psBitSetSet(bs, 6);  // 0111 1110 == 124
-            psBitSetSet(bs, 7);  // 1111 1110 == 252
-            out = psBitSetOp(out, bs, "NOT", bs2);
-            ok( out->bits[0] == 1,
-                "psBitSetOp:           return correct psBitSet output for valid inputs"
-                " with NOT operator.");
-        }
-
-        //psBitSetToString Tests
-        //Return NULL for NULL BitSet input
-        psString bitStr = NULL;
-        {
-            bitStr = psBitSetToString(noBits);
-            ok( bitStr == NULL,
-                "psBitSetToString:     return NULL for NULL BitSet input.");
-        }
-        //Return correct string for valid BitSet input
-        {
-            psFree(bs);
-            bs = psBitSetAlloc(8);
-            psBitSetSet(bs, 2);  // 0000 0100 == 4
-            bitStr = psBitSetToString(bs);
-            ok( !strncmp(bitStr, "00000100", 10),
-                "psBitSetToString:     return correct string for valid BitSet input.");
-        }
-
-        psFree(bitStr);
-        psFree(out);
-        psFree(bs);
-        psFree(bs2);
-        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
-    }
-}
Index: trunk/psLib/test/types/tap_psBits_all.c
===================================================================
--- trunk/psLib/test/types/tap_psBits_all.c	(revision 27303)
+++ trunk/psLib/test/types/tap_psBits_all.c	(revision 27303)
@@ -0,0 +1,273 @@
+/**
+ *  C Implementation: tap_psBits_all
+ *
+ * Description:  Tests for psBitsAlloc, psBitsSet, psMemCheckBits, psBitsClear,
+ *               psBitsTest, psBitsOp, psBitsNot, psBitsToString
+ *
+ * Author: dRob <David.Robbins@mhpcc.hpc.mil>, (C) 2006
+ *
+ * Copyright: See COPYING file that comes with this distribution
+ *
+ */
+#include <pslib.h>
+#include <string.h>
+#include "tap.h"
+#include "pstap.h"
+
+
+int main(void)
+{
+    psLogSetFormat("HLNM");
+    psLogSetLevel(PS_LOG_INFO);
+    plan_tests(30);
+
+
+    // testBitsBasics()
+    {
+        psMemId id = psMemGetId();
+        psBits *noBits = NULL;
+        psBits *bs = NULL;
+
+        //Return properly allocated 0-size psBits
+        {
+            bs = psBitsAlloc(0);
+            ok( bs != NULL && psMemCheckBits(bs) && bs->n == 0,
+                "psBitsAlloc:         return properly allocated psBits.");
+        }
+        //Return properly allocated psBits
+        {
+            psFree(bs);
+            bs = psBitsAlloc(8);
+            ok( bs != NULL && psMemCheckBits(bs) && bs->n == 8,
+                "psBitsAlloc:         return properly allocated psBits.");
+        }
+        //Make sure psMemCheckBits works correctly - return false
+        if (0) {
+            int j = 2;
+            ok( !psMemCheckBits(&j),
+                "psMemCheckBits:      return false for non-Bits input.");
+        }
+
+        //BitsSet Tests
+        //Return FALSE for NULL input psBits
+        {
+            bool rc = psBitsSet(NULL, 0);
+            ok(rc == false,
+                "psBitsSet:           return FALSE for NULL Bits input.");
+        }
+        //Return FALSE for negative bit input
+        {
+            bool rc = psBitsSet(bs, -1);
+            ok( rc == false,
+                "psBitsSet:           return TRUE for negative bits input.");
+            noBits = NULL;
+        }
+        //Return FALSE for out-of-range bits
+        {
+            psFree(bs);
+            bs = psBitsAlloc(8);
+            bool rc = psBitsSet(bs, 8);
+            ok( rc == false,
+                "psBitsSet:           return TRUE for out-of-range bits input.");
+            noBits = NULL;
+        }
+
+        //Return set Bits for valid inputs
+        {
+            psBitsSet(bs, 2);
+            ok( bs->bits[0] == 4,
+                "psBitsSet:           return properly set Bits for valid inputs.");
+        }
+
+        //BitsClear Tests
+        //Return FALSE for NULL input psBits
+        {
+            bool rc = psBitsClear(noBits, 0);
+            ok( rc == false,
+                "psBitsClear:         return FALSE for NULL Bits input.");
+        }
+        //Return FALSE for negative bit input
+        {
+            bool rc = psBitsClear(bs, -1);
+            ok( rc == false,
+                "psBitsClear:        return TRUE for negative bits input.");
+            noBits = NULL;
+        }
+        //Return FALSE for out-of-range bits
+        {
+            bool rc = psBitsClear(bs, 8);
+            ok( rc == false,
+                "psBitsClear:        return FALSE for out-of-range bits input.");
+            noBits = NULL;
+        }
+
+        //Return cleared Bits for valid inputs
+        {
+            psBitsClear(bs, 2);
+            ok( bs->bits[0] == 0,
+                "psBitsClear:        return properly cleared Bits for valid inputs.");
+        }
+
+        //BitsTest Tests
+        //Return false for NULL input psBits
+        {
+            ok( !psBitsTest(noBits, 0),
+                "psBitsTest:         return false for NULL Bits input.");
+        }
+        //Return false for negative bit input
+        {
+            ok( !psBitsTest(bs, -1),
+                "psBitsTest:         return false for negative bits input.");
+        }
+        //Return false for out-of-range bits
+        {
+            ok( !psBitsTest(bs, 8),
+                "psBitsTest:         return false for out-of-range bits input.");
+        }
+        //Return false for non-matching bit in Bits
+        {
+            ok( !psBitsTest(bs, 2),
+                "psBitsTest:         return false for non-matching bit in Bits.");
+        }
+        //Return false for non-matching bit in Bits
+        {
+            psBitsSet(bs, 2);
+            ok( psBitsTest(bs, 2),
+                "psBitsTest:         return true for matching bit in Bits.");
+        }
+
+        psFree(bs);
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+
+
+    // testBitsOps()
+    {
+        psMemId id = psMemGetId();
+        psBits *noBits = NULL;
+        psBits *bs = NULL;
+        bs = psBitsAlloc(8);
+        psBitsSet(bs, 2);  // 0000 0100 == 4
+        psBitsSet(bs, 3);  // 0000 1100 == 12
+        psBitsSet(bs, 4);  // 0001 1100 == 28
+        psBitsSet(bs, 5);  // 0011 1100 == 60
+        psBitsSet(bs, 6);  // 0111 1100 == 124
+        psBitsSet(bs, 7);  // 1111 1100 == 252
+        psBits *out = NULL;
+
+        //psBitsNot Tests
+        //Return NULL for NULL Bits input
+        {
+            out = psBitsNot(out, noBits);
+            ok( out == NULL,
+                "psBitsNot:          return NULL for NULL Bits input.");
+        }
+        //Return correct Bits for valid Bits input
+        {
+            out = psBitsNot(out, bs);  //bs = 1111 1100  so out should = 0000 0011 = 3
+            ok( out->bits[0] == 3,
+                "psBitsNot:          return correct Bits for valid Bits input.");
+        }
+
+        //psBitsOp Tests   out = psBitsOp(out, bs1, "op", bs2);
+        //Return NULL for NULL Bits input
+        {
+            psFree(out);
+            out = NULL;
+            out = psBitsOp(out, noBits, "op", noBits);
+            ok( out == NULL,
+                "psBitsOp:           return NULL for NULL Bits input.");
+        }
+        //Return NULL for NULL operator input
+        {
+            out = psBitsOp(out, bs, NULL, noBits);
+            ok( out == NULL,
+                "psBitsOp:           return NULL for NULL operator input.");
+        }
+        //Return NULL for invalid operator input
+        {
+            out = psBitsOp(out, bs, "XAND", noBits);
+            ok( out == NULL,
+                "psBitsOp:           return NULL for invalid operator input.");
+        }
+        //Return NULL for AND operator with NULL second Bits input
+        {
+            out = psBitsOp(out, bs, "AND", noBits);
+            ok( out == NULL,
+                "psBitsOp:           return NULL for AND operator with NULL second Bits input.");
+        }
+        //Return NULL for AND operator with Bits inputs of differing size.
+        psBits *bs2 = psBitsAlloc(16);
+        {
+            out = psBitsOp(out, bs, "AND", bs2);
+            ok( out == NULL,
+                "psBitsOp:           return NULL for AND operator with Bits inputs of"
+                " differing size.");
+        }
+        psFree(bs);
+        bs = psBitsAlloc(16);
+        psBitsSet(bs, 1);     // 0000 0010 == 2
+        psBitsSet(bs2, 2);   // 0000 0100 == 4
+        //Return correct psBits output for valid inputs with AND operator
+        {
+            out = psBitsOp(out, bs, "AND", bs2);
+            ok( out->bits[0] == 0,
+                "psBitsOp:           return correct psBits output for valid inputs"
+                " with AND operator.");
+        }
+        //Return correct psBits output for valid inputs with OR operator
+        {
+            out = psBitsOp(out, bs, "OR", bs2);
+            ok( out->bits[0] == 6,
+                "psBitsOp:           return correct psBits output for valid inputs"
+                " with OR operator.");
+        }
+        //Return correct psBits output for valid inputs with XOR operator
+        psBitsSet(bs2, 1);     // 0000 0110 == 6
+        {
+            out = psBitsOp(out, bs, "XOR", bs2);
+            ok( out->bits[0] == 4,
+                "psBitsOp:           return correct psBits output for valid inputs"
+                " with XOR operator.");
+        }
+        //Return correct psBits output for valid inputs with NOT operator
+        {
+            psFree(out);
+            out = psBitsAlloc(0);
+            psBitsSet(bs, 2);  // 0000 0110 == 4
+            psBitsSet(bs, 3);  // 0000 1110 == 12
+            psBitsSet(bs, 4);  // 0001 1110 == 28
+            psBitsSet(bs, 5);  // 0011 1110 == 60
+            psBitsSet(bs, 6);  // 0111 1110 == 124
+            psBitsSet(bs, 7);  // 1111 1110 == 252
+            out = psBitsOp(out, bs, "NOT", bs2);
+            ok( out->bits[0] == 1,
+                "psBitsOp:           return correct psBits output for valid inputs"
+                " with NOT operator.");
+        }
+
+        //psBitsToString Tests
+        //Return NULL for NULL Bits input
+        psString bitStr = NULL;
+        {
+            bitStr = psBitsToString(noBits);
+            ok( bitStr == NULL,
+                "psBitsToString:     return NULL for NULL Bits input.");
+        }
+        //Return correct string for valid Bits input
+        {
+            psFree(bs);
+            bs = psBitsAlloc(8);
+            psBitsSet(bs, 2);  // 0000 0100 == 4
+            bitStr = psBitsToString(bs);
+            ok( !strncmp(bitStr, "00000100", 10),
+                "psBitsToString:     return correct string for valid Bits input (%s).", bitStr);
+        }
+
+        psFree(bitStr);
+        psFree(out);
+        psFree(bs);
+        psFree(bs2);
+        ok(!psMemCheckLeaks(id, NULL, NULL, false), "no memory leaks");
+    }
+}
