tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
signbit.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_CMATH_SIGNBIT_HPP
4#define TETL_CMATH_SIGNBIT_HPP
5
6#include <etl/_config/all.hpp>
7
9
10namespace etl {
11
12namespace detail {
13
14template <typename T>
15[[nodiscard]] constexpr auto signbit_fallback(T arg) noexcept -> bool
16{
17 return arg == T(-0.0) || arg < T(0);
18}
19
20} // namespace detail
21
31[[nodiscard]] constexpr auto signbit(float arg) noexcept -> bool
32{
34 return detail::signbit_fallback(arg);
35 }
36#if __has_builtin(__builtin_signbit) and not defined(TETL_COMPILER_CLANG)
37 return __builtin_signbit(arg);
38#else
39 return detail::signbit_fallback(arg);
40#endif
41}
42
52[[nodiscard]] constexpr auto signbit(double arg) noexcept -> bool
53{
55 return detail::signbit_fallback(arg);
56 }
57#if __has_builtin(__builtin_signbit) and not defined(TETL_COMPILER_CLANG)
58 return __builtin_signbit(arg);
59#else
60 return detail::signbit_fallback(arg);
61#endif
62}
63
73[[nodiscard]] constexpr auto signbit(long double arg) noexcept -> bool
74{
76 return detail::signbit_fallback(arg);
77 }
78#if __has_builtin(__builtin_signbit) and not defined(TETL_COMPILER_CLANG)
79 return __builtin_signbit(arg);
80#else
81 return detail::signbit_fallback(arg);
82#endif
83}
84
85} // namespace etl
86
87#endif // TETL_CMATH_SIGNBIT_HPP
constexpr auto arg(complex< T > const &z) noexcept -> T
Definition arg.hpp:15
Definition adjacent_find.hpp:8
constexpr auto is_constant_evaluated() noexcept -> bool
Detects whether the function call occurs within a constant-evaluated context. Returns true if the eva...
Definition is_constant_evaluated.hpp:16
constexpr auto signbit(half arg) noexcept -> bool
Definition half.hpp:74