search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

純C下無號Byte單一Bit設定 – jashliao部落格

純C下無號Byte單一Bit設定與反解哪幾個Bit被設定 


線上執行: https://www.tutorialspoint.com/compile_c_online.php


程式碼:

#include 
#include 

unsigned char C_Byte_setBit(unsigned char data,int num)
{//移動次數(1,2,3,4,5,6,7,8)對應的值=1,2,4,8,16,32,64,128
    unsigned char d=1;//2^0
    if(num>0)
    {
        d=d<1
    printf("%d\n", d);
    d=C_Byte_setBit(d,8);//out->128+1
    printf("%d\n", d);
    d=C_Byte_setBit(d,2);//out->128+1+3
    printf("%d\n", d);
	
    printf("have:");
    for(i=0;i<8;i++)
    {
        c=1;
        c=c<0)
        {
            printf("%d,",i+1);
        }
    }
    printf("\n");
    
	return 0;
}





PS.

    嵌入式(單晶片) C/C++ 位元資料儲存與解析
    使用OR運算儲存(寫入),使用AND運算解析(讀取) [子網路遮罩也是利用這觀念]



熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦