程序中的科学计数法
今天學c看到const int a=1e6+10不是很理解
查了很多人的博客后才知道這是科學計數法的一種表示形式,為了避免自己忘記,記錄一下
代碼:
#include<bits/stdc++.h> using namespace std; const int a=1e6+10; int main(){cout<<a<<endl; }結果
可以理解為1*e(10)^6+10即1乘以10的六次方加10;
#include<bits/stdc++.h> using namespace std; const int a=6.555e6+10; int main(){cout<<a<<endl; }同理6.555e6+10=
?所以這里可以把e6理解為十的六次方
#include<bits/stdc++.h> using namespace std; const int a=6.555e+4; int main(){cout<<a<<endl; }結果?
?此時理解為6.555*10^4這里的+4代表次方
當科學計數法的+變-時即為10的負幾次方,例如下列代碼
#include<bits/stdc++.h> using namespace std; const float a=6.555e-4; int main(){cout<<a<<endl; }結果
?此時6.555e-4代表6.555*0.1^4
#include<bits/stdc++.h> using namespace std; const float a=1e-1-2; int main(){cout<<a<<endl; }結果
?1*0.1-2=-1.9
綜上:科學計數法的表示形式為:實數e+(-)整數
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
總結
- 上一篇: 基于opencv,C++实现中值滤波器
- 下一篇: CentOS hping3安装和应用