VC 数字转化为十六进制字符串
来源:互联网 发布:快递不送货上门 知乎 编辑:程序博客网 时间:2024/04/30 22:50
//#include "stdafx.h"
#include "string"
using namespace std;
#pragma pack(push,__mytest__,1)
union TEST_union8
{
unsigned char c[8];
__int32 x32;
__int64 x64;
double d;
};
#pragma pack(pop,__mytest__)
char digit[ 17 ] = "0123456789ABCDEF";
string int_to_str16( int x )
{
TEST_union8 u;
int i,j;
char buf[9];
buf[8]=0;
u.x32 =x ; j=0;
for (i=3;i>=0;i--)
{
int c = u.c[i];
buf[j++] = digit[ c>>4 ];
buf[j++] = digit[ c & 0xf ];
}
return buf;
}
string int64_to_str16( __int64 x )
{
TEST_union8 u;
int i,j;
char buf[17];
buf[16]=0;
u.x64 =x ; j=0;
for (i=7;i>=0;i--)
{
int c = u.c[i];
buf[j++] = digit[ c>>4 ];
buf[j++] = digit[ c & 0xf ];
}
return buf;
}
string double_to_str16( double x )
{
TEST_union8 u;
int i,j;
char buf[17];
buf[16]=0;
u.d =x ; j=0;
for (i=7;i>=0;i--)
{
int c = u.c[i];
buf[j++] = digit[ c>>4 ];
buf[j++] = digit[ c & 0xf ];
}
return buf;
}
int main()
{
printf("/n%s/n", int_to_str16(65).c_str());
__int64 x64 = 12345678901234567890;
printf("/n%s/n", int64_to_str16(x64).c_str());
printf("/n%s/n", double_to_str16( 1.5).c_str());
getchar();
return 0;
}
- VC 数字转化为十六进制字符串
- 字符串转化为十六进制
- 十六进制数字转化为汉字
- VC将输入框中的数字字符串转化为数字
- 将字符串转化为十六进制
- QT 十六进制字符串转化为十六进制编码
- 开源polarssl加密库使用详解之一:十六进制字符串转化为十六进制数字
- 字符串转化为数字
- 字符串转化为数字
- 字符串转化为数字
- 十六进制字符串转换为十六进制数字
- 十进制字符串转化为十六进制字符串
- java十六进制字符串 转化为整形
- iOS 中十六进制字符串转化为UIColor
- 十六进制字符串转化为十进制数值
- Unicode-数字转化为字符串
- 字符串转化为数字函数
- 数字转化为字符串函数
- mysql基本命令
- CSS解决未知高度垂直居中方法
- CSS解决未知高度垂直居中方法
- C程序设计语言(第2版)摘要
- 设计模式(C++实现)之Command
- VC 数字转化为十六进制字符串
- iis应用程序池 内存溢出错误 System.OutOfMemoryException
- GCC编译C程序需要注意文件名后缀的问题
- VC获取本机计算机名
- [QTP] Add-in manager的学习
- linux--ssh
- Oracle锁机制锁问题的详细分析
- ORACLE里锁
- 简单的小例子 绕过IPV6 获取IPV4