tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
abs.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
#ifndef TETL_NUMERIC_ABS_HPP
3
#define TETL_NUMERIC_ABS_HPP
4
5
#include <
etl/_limits/numeric_limits.hpp
>
6
7
namespace
etl
{
8
11
template
<
typename
Type>
12
[[nodiscard]]
constexpr
auto
abs
(Type input)
noexcept
-> Type
13
{
14
using
limits =
etl::numeric_limits<Type>
;
15
if
constexpr
(limits::is_signed or not limits::is_specialized) {
16
if
(input < 0) {
17
return
static_cast<
Type
>
(-input);
18
}
19
return
input;
20
}
else
{
21
return
input;
22
}
23
}
24
25
}
// namespace etl
26
27
#endif
// TETL_NUMERIC_ABS_HPP
etl::abs
constexpr auto abs(complex< T > const &z) -> T
Definition
abs.hpp:13
etl
Definition
adjacent_find.hpp:8
numeric_limits.hpp
etl::numeric_limits
Definition
numeric_limits.hpp:17
include
etl
_numeric
abs.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0