/*====================================================/ / Name: bitFunctions.cc / / Author: Joy Schoenberger / / Date: April 2002 / / Purpose: Implementation of bitwise functions for / / CS710 Masters research project: Genetic / / Algorithms for Musical Composition with / / Coherency Through Genotype / /====================================================*/ #include "bitFunctions.h" unsigned int setBit(unsigned int value, int index){ unsigned int Mask = (unsigned int)pow(2.0,(double)index); return (value | Mask); } unsigned int setAll(){ return INT_MAX; } bool isSet(unsigned int value, int index){ unsigned int Mask, test; Mask = (unsigned int)pow(2.0,(double)index); test = value | Mask; return (test == value ); } unsigned int unset(unsigned int value, int index){ unsigned int Mask = (unsigned int)pow(2.0,(double)index); if(isSet(value,index)) return (value ^ Mask); else return value; } unsigned int clearAll(){ return 0; } int numSet(unsigned int value){ // returns number of set bits int sum = 0; for(int i = 0;(unsigned int)i