VC++字符串转换问题

[复制链接]
查看11 | 回复1 | 2011-3-20 11:07:18 | 显示全部楼层 |阅读模式
float m_a=34;
float m_b=45;
int m_c=55;
CString
temp[13];
long int j;
temp[0]="EB";
temp[1]="90";
temp[12]="4E";

temp[2].Format("%X",(m_a&(0xFF00))>>8);
temp[3].Format("%X",m_a&(0x00FF));

j=m_b*3.14159265/180*10000000;
temp[4].Format("%X",(j&(0xFF000000))>>24);
temp[5].Format("%X",(j&(0x00FF0000))>>16);
temp[6].Format("%X",(j&(0x0000FF00))>>8);
temp[7].Format("%X",(j&(0x000000FF)));

j=m_c*3.14159265/180*10000000;
temp[8].Format("%X",(j&(0xFF000000))>>24);
temp[9].Format("%X",(j&(0x00FF0000))>>16);
temp[10].Format("%X",(j&(0x0000FF00))>>8);
temp[11].Format("%X",(j&(0x000000FF)));
这样的代码,我输出的时候 tmp[2],tmp[4],tmp[8]如果计算结果是0的时候,输出就是一个0,但是我期望的结果是2BYTE的00,谁知道应该怎么改呀

回复

使用道具 举报

千问 | 2011-3-20 11:07:18 | 显示全部楼层
temp[8].Format("%02X",(j&(0xFF000000))>>24);... ...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行