WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
fabs.hpp
Go to the documentation of this file.
1/*################################################################################
2 ##
3 ## Copyright (C) 2016-2024 Keith O'Hara
4 ##
5 ## This file is part of the GCE-Math C++ library.
6 ##
7 ## Licensed under the Apache License, Version 2.0 (the "License");
8 ## you may not use this file except in compliance with the License.
9 ## You may obtain a copy of the License at
10 ##
11 ## http://www.apache.org/licenses/LICENSE-2.0
12 ##
13 ## Unless required by applicable law or agreed to in writing, software
14 ## distributed under the License is distributed on an "AS IS" BASIS,
15 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 ## See the License for the specific language governing permissions and
17 ## limitations under the License.
18 ##
19 ################################################################################*/
20
21#ifndef _gcem_fabs_HPP
22#define _gcem_fabs_HPP
23
24namespace gcem
25{
26
27/**
28 * Compile-time floating-point absolute value function
29 *
30 * @param x a real-valued input.
31 * @return the absolute value of \c x, \f$ |x| \f$, where the return type is a floating point number (float, double, or long double).
32 */
33
34template<typename T>
35constexpr
37fabs(const T x)
38noexcept
39{
40 return gcem::abs( static_cast<return_t<T>>(x) );
41}
42
43}
44
45#endif
Definition is_odd.hpp:29
constexpr T abs(const T x) noexcept
Compile-time absolute value function.
Definition abs.hpp:40
constexpr return_t< T > fabs(const T x) noexcept
Compile-time floating-point absolute value function.
Definition fabs.hpp:37
typename std::conditional< std::is_integral< T >::value, double, T >::type return_t
Definition gcem_options.hpp:77