--- /dev/null
+file(GLOB_RECURSE SOURCES "src/*.cpp")
+file(GLOB_RECURSE TESTS "src/*.test.cpp")
+list(REMOVE_ITEM SOURCES ${TESTS})
+
+add_library(nike STATIC ${SOURCES})
+target_include_directories(nike PUBLIC include)
+
+nncc_find_package(GTest QUIET)
+
+if(NOT GTest_FOUND)
+ return()
+endif(NOT GTest_FOUND)
+
+add_executable(nike_test ${TESTS})
+target_link_libraries(nike_test nike)
+target_link_libraries(nike_test gtest_main)
+add_test(nike_test nike_test)
--- /dev/null
+## What is "nike"?
+
+"nike" is a collection of **numeric** value comparison routines.
+- "nike" is a combination of two words: "numeric" and "dike". FYI, "dike" is the goddess of justice in ancient Greek culture.
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NIKE_ABSOLUTE_EPSILON_EQUAL_H__
+#define __NIKE_ABSOLUTE_EPSILON_EQUAL_H__
+
+namespace nike
+{
+
+class AbsoluteEpsilonEqualFunctor
+{
+public:
+ friend AbsoluteEpsilonEqualFunctor absolute_epsilon_equal(float);
+
+private:
+ AbsoluteEpsilonEqualFunctor(float tolerance) : _tolerance{tolerance}
+ {
+ // DO NOTHING
+ }
+
+public:
+ bool operator()(float lhs, float rhs) const;
+
+private:
+ float _tolerance;
+};
+
+/**
+ * @note AbsoluteEpsilonEqualFunctor uses its own rule for NaN values.
+ *
+ * For example, "NAN == NAN" is false but "absolute_epsilon_equal(0.001f)(NAN, NAN)" is true.
+ */
+AbsoluteEpsilonEqualFunctor absolute_epsilon_equal(float tolerance);
+
+} // namespace nike
+
+#endif // __NIKE_ABSOLUTE_EPSILON_EQUAL_H__
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "nike/AbsoluteEpsilonEqual.h"
+
+#include <cmath>
+#include <cfloat>
+
+namespace nike
+{
+
+bool AbsoluteEpsilonEqualFunctor::operator()(float lhs, float rhs) const
+{
+ if (std::isnan(lhs) && std::isnan(rhs))
+ {
+ return true;
+ }
+
+ const auto diff = std::fabs(lhs - rhs);
+
+ return diff <= _tolerance;
+}
+
+AbsoluteEpsilonEqualFunctor absolute_epsilon_equal(float tolerance)
+{
+ return AbsoluteEpsilonEqualFunctor{tolerance};
+}
+
+} // namespace nike
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "nike/AbsoluteEpsilonEqual.h"
+
+#include <cmath> // For "NAN"
+
+#include <gtest/gtest.h>
+
+TEST(AbsoluteEpsilonEqualTest, tolerance)
+{
+ auto equal = nike::absolute_epsilon_equal(0.001f);
+
+ ASSERT_TRUE(equal(NAN, NAN));
+ ASSERT_TRUE(equal(1.0f, 1.0f));
+ ASSERT_FALSE(equal(1.0f, 2.0f));
+ ASSERT_TRUE(equal(1.0f, 1.0f + 0.0001f));
+}