| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 649 人关注过本帖
标题:[求助]浮点数存储问题(空间实体的理解)
取消只看楼主 加入收藏
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
快速回复:[求助]浮点数存储问题(空间实体的理解)
数据加载中...
 
   



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

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