[clang] Fix crashes when passing VLA to va_arg (#119563)
[llvm-project.git] / libcxx / test / std / numerics / numarray / valarray.nonmembers / valarray.transcend / valarray_helper.h
blobd68dac071c6895791b64246c3fd0c01505ae8034
1 #ifndef LIBCPP_TEST_VALARRAY_HELPER_H
2 #define LIBCPP_TEST_VALARRAY_HELPER_H
4 #include <cmath>
6 // Returns whether `x` and `y` are equal, up to the given number of
7 // significant digits after the decimal.
8 //
9 // Specifically, we look whether `abs(x - y) < epsilon`, where epsilon
10 // is `(1 / 10)^p`, assuming p is the number of digits we care about.
11 // This means we're basically looking whether `abs(x - y)` is less
12 // than `0.00..001` for some number of digits.
13 inline bool is_about(double x, double y, int significant_digits) {
14 double epsilon = std::pow(1.0 / 10.0, significant_digits);
15 return std::abs(x - y) < epsilon;
18 #endif /* LIBCPP_TEST_VALARRAY_HELPER */