C ch11重點整理-Bit Operation
来源:互联网 发布:路由器mac什么意思 编辑:程序博客网 时间:2024/04/29 13:31
- 大部份的高階語言不需要bit operation而low-level coding時,像寫驅動程式、或pixel等級的graphic programming則需要bit operation.
- 在C裡,一個char為一個byte;一個byte,則為8個bits
- Bit structure可以用c的16進位數字代表,如: “0x36” ,則為 “00110110”的代表,16進位在printf() 是使用 %x來表示,8進位則為%o。
- &: bitwise and
- |: bitwise or
- ^ :bitwise xor
- <<: shift left 比較特別的利用是 I = j>> 3 ,則等於I = j * (2*2*2)
- >> :shift right 比較特別的到用是 I= j<< 3 ,則等於 I = j / (2*2*2)
- ~ :bitwise not
C 語言printf()並沒有能代表binary的符號,得自己寫個 int_to_bit()程式
設定bits
如:const int ERROR = 0x01
練習:寫一個clear bit的macro
#include <stdio.h>
#define clear_bit(x) (x)=(x)>>24;
main()
{
int a=0xAF;
clear_bit(a)
printf("%d\n",a);
return 0;
}
0 0
- C ch11重點整理-Bit Operation
- bit operation
- Bit Operation
- Bit Operation
- C Ch5重點整理-Array
- C Ch6~Ch9重點整理-String
- C Ch10重點整理-Preprocessor
- C Ch12 重點整理-Structure
- C ch13重點整理-Pointer
- The example of Bit Operation in C programming
- 面试题总结 - C 语言 - 位操作(bit operation)
- Bit movement operation
- Surprise of bit operation!
- Bit Operation problems
- Bit Operation exchange & Tmp exchange
- Leetcode - Bit Operation/Array- Single Number
- Java I/O : Bit Operation 位运算
- Java I/O : Bit Operation 位运算
- Asp.net MVC在View里动态捆绑压缩引用的js
- 上帝模式,,即"God Mode”,或称为“完全控制面板”
- Asp.net MVC在View里动态捆绑压缩引用的js
- 尝试把vim打造成为IDE
- Asp.net MVC在View里动态捆绑压缩引用的js
- C ch11重點整理-Bit Operation
- Asp.net MVC在View里动态捆绑压缩引用的js
- 初识指针7(void类型指针的认识)
- poj1789 prim最小生成树
- test
- 追踪TCP_IP实现过程
- linux下小试redis demo
- c++排序算法——快速排序
- cocos2dx 3.x Value、Vector和Map的认识