8#ifndef LIBFXD_FIXED_HPP
9#define LIBFXD_FIXED_HPP
15#include "detail/types.hpp"
36 typename Raw = detail::select_int_t<Int + Frac>
42 static_assert(std::numeric_limits<Raw>::is_specialized,
43 "raw type is not usable, lacks std::numeric_limits support");
56 detail::type_width<raw_type>;
60 static_assert(
bits > 0);
72 constexpr fixed() noexcept = default;
78 template<
std::integral I>
79 constexpr
fixed(I i) noexcept;
82 template<
std::floating_point Flt>
83 constexpr
fixed(Flt f) noexcept;
87 template<
int Int2,
int Frac2, typename Raw2>
88 requires (detail::is_safe_conversion_v<Int2, Frac2, Raw2,
90 constexpr
fixed(const
fixed<Int2, Frac2, Raw2>& other) noexcept;
107 operator
bool() const noexcept;
110 template<
std::integral I>
112 operator I() const noexcept;
115 template<
std::floating_point F>
117 operator F() const noexcept;
120 template<
int Int2,
int Frac2, typename Raw2>
123 operator
fixed<Int2, Frac2, Raw2>() const noexcept;
131 using
ufixed =
fixed<Int, Frac, detail::select_uint_t<Int + Frac>>;
This is the namespace where the entire library is defined.
The fixed-point class template.
constexpr fixed() noexcept=default
Defaulted constructor.
static constexpr int raw_bits
How many bits are used for storage (can be larger than bits).
static constexpr int int_bits
How many integral bits were requested.
static constexpr int bits
How many bits were requested in total.
static constexpr int frac_bits
How many fractional bits were requested.
Raw raw_type
The integral type that will hold the raw representation of the value.
raw_type raw_value
The raw value, stored as a bitfield.