32位数据转8位数据和8位数据转32位数据

前端之家收集整理的这篇文章主要介绍了32位数据转8位数据和8位数据转32位数据前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1。32位数据转换为8位数据

UINT32 m_num32[512];//32里面有参数

UINT8 m_num8[2048];

UINT8 m_temp;

memset(m_num8,2048);

for(int i = 0; i < 512; i++)

{

m_temp = m_num32[i] >> 24;

m_num8[i] = m_temp;

m_temp = m_num32[i] >> 16;

m_num8[i + 512] = m_temp;

m_temp = m_num32[i] >> 8;

m_num8[i + 1024] = m_temp;

m_temp = m_num32[i];

m_num8[i + 1536] = m_temp;

}

2.8位数据转换位32位数据

UINT32 m_num32[512];

UINT8 m_num8[2048];//8里面有数据

UINT8 m_temp;

memset(m_num32,512);

for(int i = 0; i < 512; i++)

{

m_temp = m_num8[i];

m_num32[i] |= m_temp << 24;

m_temp = m_num8[i + 512];

m_num32[i] |= m_temp << 16;

m_temp = m_num8[i + 1024];

m_num32[i] |= m_temp << 8;

m_temp = m_num8[i + 1536];

m_num32[i] |= m_temp;

}

猜你在找的Windows相关文章