您的位置:首页 > 其它

浮点数转换成二进制的方法

2017-04-09 00:50 232 查看
using namespace std;

int main(){

int i;

float f=-6.9072;

//将float指针转换为字符指针

unsigned char* p=reinterpret_cast<unsigned char*>(&f);

cout<<hex;//print bytes of f in hex

for(i=0; i<sizeof(float);i++)

cout<<static_cast<int>(p[i])<<endl;

}</span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: