]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef BOOST_MATH_ALMOST_EQUAL_HPP |
2 | #define BOOST_MATH_ALMOST_EQUAL_HPP | |
3 | ||
4 | // Copyright (c) 2006 Johan Rade | |
5 | ||
6 | // Distributed under the Boost Software License, Version 1.0. | |
7 | // (See accompanying file LICENSE_1_0.txt | |
8 | // or copy at http://www.boost.org/LICENSE_1_0.txt) | |
9 | ||
10 | #include <cmath> | |
11 | ||
12 | template<class ValType> | |
13 | bool almost_equal(ValType a, ValType b) | |
14 | { | |
15 | const ValType e = static_cast<ValType>(0.00001); | |
16 | return (a - e * std::abs(a) <= b + e * std::abs(b)) | |
17 | && (a + e * std::abs(a) >= b - e * std::abs(b)); | |
18 | } | |
19 | ||
20 | #endif |