双十进制数转换为十六进制字符串
Double decimal number convert to HEX string
我想在 MFC 中将十进制数 (17592186044416) 转换为十六进制字符串。我尝试使用
code 1:
double ftw = 0;
CString str;
str.Format(_T("%X"), ftw); //this will always be 0 in HEX
code 2:
char t1[100];
_itoa_s(ftw, t1, 16);// this will give me 80000000 in HEX
好像是 str.Format(_T("%X"), ftw);和 _itoa_s(ftw, t1, 16);功能有限制。我可以使用任何其他命令将 17592186044416 转换为十六进制字符串吗?
谢谢。
您可以将其转换为 64 位整数,然后在格式字符串中使用 I64
限定符进行格式化:
double ftw = 17592186044416.0;
CString str;
str.Format(_T("%I64X"), (__int64)ftw);
对于上面的示例,str
将具有字符串 "100000000000"
我想在 MFC 中将十进制数 (17592186044416) 转换为十六进制字符串。我尝试使用
code 1:
double ftw = 0;
CString str;
str.Format(_T("%X"), ftw); //this will always be 0 in HEX
code 2:
char t1[100];
_itoa_s(ftw, t1, 16);// this will give me 80000000 in HEX
好像是 str.Format(_T("%X"), ftw);和 _itoa_s(ftw, t1, 16);功能有限制。我可以使用任何其他命令将 17592186044416 转换为十六进制字符串吗? 谢谢。
您可以将其转换为 64 位整数,然后在格式字符串中使用 I64
限定符进行格式化:
double ftw = 17592186044416.0;
CString str;
str.Format(_T("%I64X"), (__int64)ftw);
对于上面的示例,str
将具有字符串 "100000000000"