#include <float.h>
#include <math.h>
#include <iostream>
using std::cout;
using std::endl;
int main()
{
//判断double值是否为0
double dValue = 0.0;
if (fabs(dValue) < DBL_EPSILON )
{
std::cout << "dValue的值为零" << std::endl;
}
else
{
std::cout << "dValue的值不为零" << std::endl;
}
double dValue0 = 1e-15;
if (fabs(dValue0) < DBL_EPSILON)
{
std::cout << "dValue0的值为零" << std::endl;
}
else
{
std::cout << "dValue0的值不为零" << std::endl;
}
//C++/C科学计数法
double scientificValue0 = 1e-2; //0.01
double scientificValue1 = 1e3; //1000
cout << scientificValue0 << endl
<< scientificValue1 <<endl;
system("pause");
return 0;
}
引用一句话:
再也不用睁大眼睛去数有多少零了。