4#ifndef TETL_CMATH_SIGNBIT_HPP
5#define TETL_CMATH_SIGNBIT_HPP
7#include <etl/_config/all.hpp>
9#include <etl/_3rd_party/gcem/gcem.hpp>
10#include <etl/_array/array.hpp>
11#include <etl/_bit/bit_cast.hpp>
12#include <etl/_concepts/integral.hpp>
13#include <etl/_cstdint/int_t.hpp>
14#include <etl/_type_traits/is_constant_evaluated.hpp>
20template <
typename Float>
21[[nodiscard]]
constexpr auto signbit_fallback(Float arg)
noexcept ->
bool
23 if constexpr (
sizeof(Float) == 4) {
24 auto const bits =
etl::bit_cast<
etl::int32_t>(arg);
26 }
else if constexpr (
sizeof(Float) == 8) {
27 auto const bits =
etl::bit_cast<
etl::int64_t>(arg);
30 return etl::detail::gcem::signbit(arg);
34inline constexpr struct signbit {
35 template <
typename Float>
36 [[nodiscard]]
constexpr auto operator()(Float arg)
const noexcept ->
bool
39 if constexpr (is_same_v<Float,
float>) {
40#if __has_builtin(__builtin_signbitf)
41 return __builtin_signbitf(arg);
44 if constexpr (is_same_v<Float,
double>) {
45#if __has_builtin(__builtin_signbit)
46 return __builtin_signbit(arg);
49 if constexpr (is_same_v<Float,
long double>) {
50#if __has_builtin(__builtin_signbitl)
51 return __builtin_signbitl(arg);
55 return signbit_fallback(arg);
73 return etl::detail::signbit(arg);
85 return etl::detail::signbit(arg);
97 return etl::detail::signbit(arg);
constexpr auto signbit(long double arg) noexcept -> bool
Determines if the given floating point number arg is negative.
Definition signbit.hpp:95
constexpr auto signbit(float arg) noexcept -> bool
Definition signbit.hpp:71
constexpr auto signbit(double arg) noexcept -> bool
Determines if the given floating point number arg is negative.
Definition signbit.hpp:83
Definition adjacent_find.hpp:9
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:17