#include "bytes.h"
Go to the source code of this file.
Functions | |
byte | getbit (byte b, int n) |
unsigned int | getbitint (unsigned int b, int n) |
void | setbit (byte *b, int n, byte v) |
void | setbitint (unsigned int *b, int n, byte v) |
void | printbyte (byte b) |
void | printint (unsigned int b) |
int | random_bit (void) |
void | randomize_byte (byte *b) |
|
Definition at line 9 of file bits.c. References byte. Referenced by decode_bch(). 00014 {
00015 return (b >> (8-n)) & 1;
00016 }
|
|
Definition at line 18 of file bits.c. Referenced by checkcrc4(), encode_bch(), make_backward_control(), make_forward_control(), and makecrc4(). 00023 {
00024 return (b >> (16-n)) & 1;
00025 }
|
|
Definition at line 59 of file bits.c. 00061 { 00062 int j; 00063 for(j=7;j>=0;j--) 00064 if ((int) b & (1 << j)) 00065 printf("1"); 00066 else 00067 printf("0"); 00068 printf("\n"); 00069 }
|
|
Definition at line 71 of file bits.c. 00073 { 00074 int j; 00075 for(j=15;j>=0;j--) 00076 if ((int) b & (1 << j)) 00077 printf("1"); 00078 else 00079 printf("0"); 00080 printf("\n"); 00081 }
|
|
Definition at line 84 of file bits.c. Referenced by randomize_byte(). 00086 : either a 1 or a 0. 00087 * 00088 * there is approximately an equal chance of each. 00089 */ 00090 { 00091 static int random_counter = -1; 00092 static int r; 00093 00094 if (random_counter == -1) { 00095 r = rand(); 00096 random_counter = 30; 00097 } 00098 return ((r & (1 << random_counter--))?1:0); 00099 }
|
|
Definition at line 101 of file bits.c. References random_bit(), and setbit(). Referenced by code_audio(). 00105 { 00106 int i; 00107 00108 for (i=1;i<=8;i++) 00109 setbit(b,i,random_bit()); 00110 }
|
|
Definition at line 28 of file bits.c. Referenced by encode_bch(), and randomize_byte(). 00032 : pointer to the byte. output: none. side effect: changes 00033 the particular bit in the byte 00034 */ 00035 { 00036 if (v != 0) 00037 *b = (*b | (128 >> (n-1))); /*turn the bit on*/ 00038 else 00039 *b = (*b & (~(128 >> (n-1)))); /*turn the bit off*/ 00040 }
|
|
Definition at line 43 of file bits.c. Referenced by make_backward_control(), and make_forward_control(). 00049 : pointer to the unsigned int. output: none. side effect: 00050 changes the particular bit in the byte 00051 */ 00052 { 00053 if (v != 0) 00054 *b = (*b | (32768 >> (n-1))); /*turn the bit on*/ 00055 else 00056 *b = (*b & (~(32768 >> (n-1)))); /*turn the bit off*/ 00057 }
|