首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

C++中的bug解决办法

2012-09-16 
C++中的bug今天小弟我发现了一个错误,我也不知道算不算错误。#include iostream#include iomanip#inclu

C++中的bug
今天小弟我发现了一个错误,我也不知道算不算错误。

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
  double a;
  cin>>a;
  cout<<hex<<a<<endl;
  cout<<dec<<a<<endl;
  cout<<oct<<a<<endl;
  system("pause");
  return 0;  
}
无论浮点数a为什么数,三个的输出结果都是一样的。

[解决办法]
hex,dec,oct只能用做整形之类的。
浮点数要用其他方式:

http://blog.sina.com.cn/s/blog_4118ac240100s7ei.html

热点排行