3#ifndef TETL_CMATH_RINT_HPP
4#define TETL_CMATH_RINT_HPP
6#include <etl/_config/all.hpp>
8#include <etl/_concepts/integral.hpp>
9#include <etl/_type_traits/is_constant_evaluated.hpp>
10#include <etl/_type_traits/is_same.hpp>
16[[nodiscard]]
constexpr auto rint_fallback(T arg)
noexcept -> T
18 if constexpr (
sizeof(T) <=
sizeof(
long)) {
19 return static_cast<T>(
static_cast<
long>(arg));
21 return static_cast<T>(
static_cast<
long long>(arg));
26[[nodiscard]]
constexpr auto rint_impl(T arg)
noexcept -> T
29 if constexpr (is_same_v<T,
float>) {
30#if __has_builtin(__builtin_rintf)
31 return __builtin_rintf(arg);
34 if constexpr (is_same_v<T,
double>) {
35#if __has_builtin(__builtin_rint)
36 return __builtin_rint(arg);
39 if constexpr (is_same_v<T,
long double>) {
40#if __has_builtin(__builtin_rintl)
41 return __builtin_rintl(arg);
45 return rint_fallback(arg);
55 return detail::rint_impl(arg);
63 return detail::rint_impl(arg);
71 return detail::rint_impl(arg);
77[[
nodiscard]]
constexpr auto rint(
long double arg)
noexcept ->
long double
79 return detail::rint_impl(arg);
87 return detail::rint_impl(arg);
94[[nodiscard]]
constexpr auto rint(T arg)
noexcept ->
double
96 return rint(static_cast<
double>(arg)
);
constexpr auto rintl(long double arg) noexcept -> long double
Rounds the floating-point argument arg to an integer value (in floating-point format),...
Definition rint.hpp:85
constexpr auto rint(long double arg) noexcept -> long double
Rounds the floating-point argument arg to an integer value (in floating-point format),...
Definition rint.hpp:77
constexpr auto rint(T arg) noexcept -> double
Rounds the floating-point argument arg to an integer value (in floating-point format),...
Definition rint.hpp:94
constexpr auto rint(float arg) noexcept -> float
Rounds the floating-point argument arg to an integer value (in floating-point format),...
Definition rint.hpp:53
constexpr auto rintf(float arg) noexcept -> float
Rounds the floating-point argument arg to an integer value (in floating-point format),...
Definition rint.hpp:61
constexpr auto rint(double arg) noexcept -> double
Rounds the floating-point argument arg to an integer value (in floating-point format),...
Definition rint.hpp:69
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