W
wyddr
Unregistered / Unconfirmed
GUEST, unregistred user!
//第一个
void TStart1::transferToHexString(WORD value, char *str)
{
str[0] = (char) ((value &
0x00F0) >> 4);
str[1] = (char) (value &
0x000F);
str[2] = 0;
if (str[0] >= 10)
str[0] = str[0] + 'A' - 10;
else
str[0] = str[0] + '0';
if (str[1] >= 10)
str[1] = str[1] + 'A' - 10;
else
str[1] = str[1] + '0';
}
//---------------------------------------------------------------------------
//第二个
void TStart1::ConvertWordToHexString(WORD iValue, unsigned char *aValue)
{
int i;
aValue[0] = (unsigned char) ((iValue &
0xF000) >> 12);
aValue[1] = (unsigned char) ((iValue &
0x0F00) >> 8);
aValue[2] = (unsigned char) ((iValue &
0x00F0) >> 4);
aValue[3] = (unsigned char) (iValue &
0x000F);
aValue[4] = 0;
for (i = 0;
i < 4;
i++)
{
if (aValue >= 10)
aValue = aValue + 'A' - 10;
else
aValue = aValue + '0';
}
}
//---------------------------------------------------------------------------
//第三个
WORD TStart1::convertStrToWord(char *str)
{
WORD w = 0;
char str0, str1;
str0 = str[0];
str1 = str[1];
str[0] = str[2];
str[1] = str[3];
str[2] = str0;
str[3] = str1;
for (int i = 0;
i < 4;
i++)
{
if (str >= '0' &&
str <= '9')
w = w * 16 + str - '0';
else
w = w * 16 + 10 + str - 'A';
}
return w;
}
对关注本问题者表示谢意!!对关注本问题者表示谢意!!对关注本问题者表示谢意!!对关注本问题者表示谢意!!对关注本问题者表示谢意!!对关注本问题者表示谢意!!
void TStart1::transferToHexString(WORD value, char *str)
{
str[0] = (char) ((value &
0x00F0) >> 4);
str[1] = (char) (value &
0x000F);
str[2] = 0;
if (str[0] >= 10)
str[0] = str[0] + 'A' - 10;
else
str[0] = str[0] + '0';
if (str[1] >= 10)
str[1] = str[1] + 'A' - 10;
else
str[1] = str[1] + '0';
}
//---------------------------------------------------------------------------
//第二个
void TStart1::ConvertWordToHexString(WORD iValue, unsigned char *aValue)
{
int i;
aValue[0] = (unsigned char) ((iValue &
0xF000) >> 12);
aValue[1] = (unsigned char) ((iValue &
0x0F00) >> 8);
aValue[2] = (unsigned char) ((iValue &
0x00F0) >> 4);
aValue[3] = (unsigned char) (iValue &
0x000F);
aValue[4] = 0;
for (i = 0;
i < 4;
i++)
{
if (aValue >= 10)
aValue = aValue + 'A' - 10;
else
aValue = aValue + '0';
}
}
//---------------------------------------------------------------------------
//第三个
WORD TStart1::convertStrToWord(char *str)
{
WORD w = 0;
char str0, str1;
str0 = str[0];
str1 = str[1];
str[0] = str[2];
str[1] = str[3];
str[2] = str0;
str[3] = str1;
for (int i = 0;
i < 4;
i++)
{
if (str >= '0' &&
str <= '9')
w = w * 16 + str - '0';
else
w = w * 16 + 10 + str - 'A';
}
return w;
}
对关注本问题者表示谢意!!对关注本问题者表示谢意!!对关注本问题者表示谢意!!对关注本问题者表示谢意!!对关注本问题者表示谢意!!对关注本问题者表示谢意!!