标题:[求助]浮点数存储问题(空间实体的理解)
取消只看楼主
freeforever
Rank: 4
等 级:业余侠客
威 望:3
帖 子:368
专家分:201
注 册:2005-11-2
结帖率:66.67%
 问题点数:0 回复次数:1 
[求助]浮点数存储问题(空间实体的理解)

//=====================================
// f0312.cpp
// 空间实体的理解
//=====================================
#include<iostream>
using namespace std;
//-------------------------------------
int main(){
float f = 34.5;
int* ip = reinterpret_cast<int*>(&f);
cout<<"float address: "<<&f<<"=>"<<f<<endl;
cout<<" int address: "<<ip<<"=>"<<*ip<<endl;
*ip = 100;
cout<<" int: "<<*ip<<endl;
cout<<"float: "<<f<<endl;
cin.get();
}//====================================

请问,输出中最后一行是怎么来的,为什么?
/*
float address: 0x241ff5c=>34.5
int address: 0x241ff5c=>1107951616
int: 100
float: 1.4013e-43
*/

搜索更多相关主题的帖子: 实体 点数 空间 
2006-09-20 20:54
freeforever
Rank: 4
等 级:业余侠客
威 望:3
帖 子:368
专家分:201
注 册:2005-11-2
得分:0 
那就明白了,我知道会变,但不知道会变成什么。

谢谢二位

其实我也很无聊!
2006-09-21 14:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-91605-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 3.092612 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved