tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
fdim.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2021 Tobias Hienzsch
3
4#ifndef TETL_CMATH_FDIM_HPP
5#define TETL_CMATH_FDIM_HPP
6
7#include <etl/_cmath/fmax.hpp>
8
9namespace etl {
10
11/// \ingroup cmath
12/// @{
13
14/// Returns the positive difference between x and y, that is, if x>y,
15/// returns x-y, otherwise (if x≤y), returns +0.
16/// \details https://en.cppreference.com/w/cpp/numeric/math/fdim
17[[nodiscard]] constexpr auto fdim(float x, float y) noexcept -> float
18{
19 return etl::fmax(x - y, 0);
20}
21[[nodiscard]] constexpr auto fdimf(float x, float y) noexcept -> float
22{
23 return etl::fmax(x - y, 0);
24}
25[[nodiscard]] constexpr auto fdim(double x, double y) noexcept -> double
26{
27 return etl::fmax(x - y, 0);
28}
29[[nodiscard]] constexpr auto fdim(long double x, long double y) noexcept -> long double
30{
31 return etl::fmax(x - y, 0);
32}
33[[nodiscard]] constexpr auto fdiml(long double x, long double y) noexcept -> long double
34{
35 return etl::fmax(x - y, 0);
36}
37
38/// @}
39
40} // namespace etl
41
42#endif // TETL_CMATH_FDIM_HPP
constexpr auto fdiml(long double x, long double y) noexcept -> long double
Definition fdim.hpp:33
constexpr auto fdim(long double x, long double y) noexcept -> long double
Definition fdim.hpp:29
constexpr auto fdim(double x, double y) noexcept -> double
Definition fdim.hpp:25
constexpr auto fmax(double x, double y) noexcept -> double
Definition fmax.hpp:28
constexpr auto fmax(long double x, long double y) noexcept -> long double
Definition fmax.hpp:33
constexpr auto fdimf(float x, float y) noexcept -> float
Definition fdim.hpp:21
constexpr auto fmax(float x, float y) noexcept -> float
Definition fmax.hpp:18
constexpr auto fdim(float x, float y) noexcept -> float
Definition fdim.hpp:17
Definition adjacent_find.hpp:9