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

!关于pow函数的强制类型转换

2012-05-14 
求助!关于pow函数的强制类型转换#includeiostream#includemath.husing namespace stdint main(void){

求助!关于pow函数的强制类型转换
#include<iostream>
#include<math.h>

using namespace std;

int main(void){
  int n;
  while(1){
  cin>>n;
  cout<<pow(10,n)<<" "<<(int)pow(10,n)<<endl;
  }
  return 0;
}

运行程序,输入2,得到输出100 99

很奇怪为什么用pow(float x,float y)求x的y次方,结果强制转换为整型后会少1???
注:环境是dev c++

[解决办法]
结果可能是99.9999
[解决办法]

探讨
结果可能是99.9999

热点排行