Main Page | Class List | File List | Class Members | File Members

bits.h

Go to the documentation of this file.
00001 /* BITS.H */
00002 
00003 /*
00004   BITWISE OPERATIONS, Functions to manipulate bits.  Max Luttrell,
00005   3/17/96
00006 */
00007 #ifndef _BITS_H_
00008 #define _BITS_H_
00009 
00010 #include "bytes.h"
00011 
00012 
00013 byte getbit(byte b, int n);
00014 /*
00015  * get value of bit in position n from byte b,
00016  *   where a byte has positions 12345678
00017  */
00018 
00019 unsigned int getbitint(unsigned int b, int n);
00020 /*
00021  * get value of bit in position n from unsigned int b,
00022  *   where an unsigned integer has positions 1234567890123456
00023  */
00024 
00025 void setbit(byte *b, int n, byte v);
00026 /*
00027  * set value of bit in position n of byte b to be the value v.
00028  *   a byte has positions 12345678
00029  *   input: pointer to the byte.  output: none.  side effect: changes
00030  *   the particular bit in the byte
00031  */
00032 
00033 void setbitint(unsigned int *b, int n, byte v);
00034 /*
00035  * set value of bit in position n of unsigned int b to be the value v.
00036  *
00037  *                       MSB      1   LSB
00038  *      a byte has positions 1234567890123456
00039  *  input: pointer to the unsigned int.  output: none.  side effect:
00040  *      changes the particular bit in the byte
00041  */
00042 
00043 void printbyte(byte b);
00044 /*
00045  * prints a byte to std output 
00046  */
00047 
00048 void printint(unsigned int b);
00049 /* 
00050  * prints an unsigned int to std output 
00051  */
00052 
00053 int random_bit(void);
00054 /*
00055  * returns: either a 1 or a 0.
00056  *
00057  * there is approximately an equal chance of each.
00058  */
00059 
00060 void randomize_byte(byte *b);
00061 /*
00062  * sets the bits inside of byte b to random values
00063  */
00064 
00065 #endif

Generated on Sun Jul 16 16:27:45 2006 by  doxygen 1.3.9.1