?? bitroutines.c
字號:
/* | | Copyright disclaimer: | This software was developed at the National Institute of Standards | and Technology by employees of the Federal Government in the course | of their official duties. Pursuant to title 17 Section 105 of the | United States Code this software is not subject to copyright | protection and is in the public domain. | | We would appreciate acknowledgement if the software is used. |*//* | Project: WCDMA simulation environment | Module: Bit manipulation routines | Author: Tommi Makelainen, NIST | Date: January 6, 1999 | | History: | January 6, 1999 Tommi Makelainen | Initial version. | */#include "bitroutines.h"/* -------------------------------------------------------------------- *//* * Function: extract_bit_from_byte * Desc.: Extract given single bit value from a given byte. * * Inputs: * byte input byte * pos bit position (7-0) 7 = leftmost, 0 = bit on the right * Returns: * bit value (0 or 1) * * Note: */char extract_bit_from_byte(char byte, int pos){ int i; char bit; bit = 0; bit = (byte >> pos) & 0x1; return (bit);}/* -------------------------------------------------------------------- *//* * Function: set_bit_in_byte * Desc.: Set a value of a single bit 'bit' in given * position 'pos' in a byte 'byte'. * * Inputs: * bit input bit value * pos bit position to set * Outputs: * byte modified byte * * Note: */int set_bit_in_byte(char bit, int pos, char *byte){ char temp_byte; temp_byte = 0; temp_byte = (bit << pos); *byte |= temp_byte; return(0);}/* -------------------------------------------------------------------- */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -