tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
sign.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_MATH_SIGN_HPP
4#define TETL_MATH_SIGN_HPP
5
6namespace etl::detail {
7
8template <typename T>
9[[nodiscard]] constexpr auto sign(T val)
10{
11 if (val < 0) {
12 return T(-1);
13 }
14 return T(1);
15}
16} // namespace etl::detail
17
18#endif // TETL_MATH_SIGN_HPP