In C++, floating-point numbers (e.g., float
, double
) can lead to precision errors when performing arithmetic operations.
You are given two floating-point numbers a
and b
, and an expected result expected_sum
.
Write a C++ program that checks if the sum of a + b
is "almost equal" to expected_sum
within a small epsilon tolerance (1e-6
).
Return "YES"
if it matches, "NO"
otherwise.
-1e9 <= a, b, expected_sum <= 1e9