2#ifndef TETL_NUMERIC_MIDPOINT_HPP
3#define TETL_NUMERIC_MIDPOINT_HPP
26template <
typename Int>
28constexpr auto midpoint(Int a, Int b)
noexcept -> Int
33 auto const diff =
static_cast<UInt
>(UInt(b) - UInt(a));
34 auto const sign =
static_cast<UInt
>(b < a);
35 auto const half =
static_cast<UInt
>((diff / 2) + (sign << shift) + (sign & diff));
37 return a +
static_cast<Int
>(
half);
41template <etl::
floating_po
int Float>
42constexpr auto midpoint(Float a, Float b)
noexcept -> Float
61template <
typename Ptr>
63constexpr auto midpoint(Ptr a, Ptr b)
noexcept -> Ptr
constexpr auto abs(complex< T > const &z) -> T
Definition abs.hpp:13
constexpr auto midpoint(Int a, Int b) noexcept -> Int
Returns half the sum of a + b. If the sum is odd, the result is rounded towards a.
Definition midpoint.hpp:28
Definition adjacent_find.hpp:8
constexpr bool is_integral_v
Definition is_integral.hpp:28
constexpr bool is_pointer_v
Definition is_pointer.hpp:30
constexpr bool is_same_v
Definition is_same.hpp:11
typename make_unsigned< T >::type make_unsigned_t
Definition make_unsigned.hpp:75
TETL_BUILTIN_PTRDIFF ptrdiff_t
etl::ptrdiff_t is the signed integer type of the result of subtracting two pointers.
Definition ptrdiff_t.hpp:14
static constexpr int digits
Definition numeric_limits.hpp:24
static constexpr auto max() noexcept
Definition numeric_limits.hpp:21
static constexpr auto min() noexcept
Definition numeric_limits.hpp:20