#pragma once //防止文件被多重包含
#include <stdio.h>
#include <stdlib.h>
#include <string> //字符串
#include <memory> //内存操作
#include <numeric> //数值计算算法
#include <math.h> //数值计算算法
#include <complex>
#include <algorithm> //min函数和max函数
using namespace std;
const float FLOATERROR = 1.0e-6F; //最小浮点数,浮点比较误差
const double DOUBLEERROR = 1.0e-15; //最小double,比较误差
const long double LONGDOUBLEERROR = 1.0e-30; //long double比较误差
const double GoldNo = 0.618033399; //黄金分割常数(1.0-0.381966)
const double inf = DBL_MAX; //无穷大
const double pi = 3.1415926535898; //圆周率
const double eps = DOUBLEERROR; //精度容许误差
//判断float浮点数相等
inline bool FloatEqual(float lhs, float rhs)
{
if (std::abs(lhs - rhs) < FLOATERROR)
return true;
else
return false;
}
//判断float浮点数不相等
inline bool FloatNotEqual(float lhs, float rhs)
{
if (std::abs(lhs - rhs) >= FLOATERROR)
return true;
else
return false;
}
//判断double浮点数相等
inline bool FloatEqual(double lhs, double rhs)
{
if (std::abs(lhs - rhs) < DOUBLEERROR)
return true;
else
return false;
}
//判断double浮点数不相等
inline bool FloatNotEqual(double lhs, double rhs)
{
if (std::abs(lhs - rhs) >= DOUBLEERROR)
return true;
else
return false;
}
//比较两long double浮点数相等
inline bool FloatEqual(long double lhs, long double rhs)
{
if (std::abs(lhs - rhs) < LONGDOUBLEERROR)
return true;
else
return false;
}
//比较两long double浮点数不相等
inline bool FloatNotEqual(long double lhs, long double rhs)
{
if (std::abs(lhs - rhs) >= LONGDOUBLEERROR)
return true;
else
return false;
}