真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

C++中按位寫入讀取數(shù)值-創(chuàng)新互聯(lián)

向 quint8類型數(shù)據(jù)中連續(xù)位寫入數(shù)值

目前成都創(chuàng)新互聯(lián)已為上千的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)站空間、網(wǎng)站托管、服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計(jì)、印江網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。
void Utils::insertValueToQuint8CtrlWord(quint8* unsigned8CtrlWord, int high_position, int low_postion, quint16 setValue)
{int len = high_position - low_postion;
	switch (len)
	{case 0:
		setValue = setValue & 0x00000001;
		break;
	case 1:
		setValue = setValue & 0x00000003;
		break;
	case 2:
		setValue = setValue & 0x00000007;
		break;
	case 3:
		setValue = setValue & 0x0000000f;
		break;
	case 4:
		setValue = setValue & 0x0000001f;
		break;
	case 5:
		setValue = setValue & 0x0000003f;
		break;
	case 6:
		setValue = setValue & 0x0000007f;
		break;
	case 7:
		setValue = setValue & 0x000000ff;
		break;
	default:
		break;
	}

	bitset<32>binaryControlWord(*unsigned8CtrlWord);
	for (int i = low_postion; i<= high_position; i++)
	{binaryControlWord.reset(i);
	}

	bitset<32>binaryValue(setValue);
	binaryValue<<= low_postion;
	binaryControlWord |= binaryValue;
	*unsigned8CtrlWord = (quint32)binaryControlWord.to_ulong();
}

從 quint8類型數(shù)據(jù)中連續(xù)位讀取數(shù)值

int Utils::getValueFromQuint8CtrlWord(quint8* unsigned8CtrlWord, int high_position, int low_postion)
{int ret = 0;

	bitset<16>binaryCtrlWord(*unsigned8CtrlWord);

	for (int i = 0; i< low_postion; i++) binaryCtrlWord.reset(i);
	for (int i = high_position + 1; i<= 7; i++) binaryCtrlWord.reset(i);

	binaryCtrlWord >>= low_postion;

	ret = (quint8)binaryCtrlWord.to_ulong();

	return ret;
}

說(shuō)明:quint16,quint32,quint64類型數(shù)據(jù)類似方法實(shí)現(xiàn)。

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧


分享題目:C++中按位寫入讀取數(shù)值-創(chuàng)新互聯(lián)
鏈接分享:http://weahome.cn/article/ddohgg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部