We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CaptainBlackboard/D#0050-C++中浮点值做比较的正确方法/code/main.cpp
Lines 6 to 9 in 39c0078
cppinsights:
bool isEqual(const double first, const double second, const double epsilon) { return static_cast<double>(abs(static_cast<int>(first - second))) < epsilon; }
first-second 转换为 int 已经失去精确度。
first-second
int
Example: https://compiler-explorer.com/z/TPrcsGbEE
The text was updated successfully, but these errors were encountered:
No branches or pull requests
CaptainBlackboard/D#0050-C++中浮点值做比较的正确方法/code/main.cpp
Lines 6 to 9 in 39c0078
cppinsights:
first-second
转换为int
已经失去精确度。Example: https://compiler-explorer.com/z/TPrcsGbEE
The text was updated successfully, but these errors were encountered: