libfxd 0.2.dev
A fixed-point library for C++.
|
This is the namespace where the entire library is defined. More...
Namespaces | |
namespace | down |
Round down. | |
namespace | except |
Throw on overflow. | |
namespace | expect |
Return fxd::expect::maybe<...> result. | |
namespace | saturate |
Clamp on overflow. | |
namespace | up |
Round up. | |
namespace | zero |
Round to zero. | |
Classes | |
struct | fixed |
The fixed-point class template. More... | |
struct | is_fixed_point< fixed< Int, Frac, Raw > > |
Test if a type is fxd::fixed . More... | |
struct | is_signed_fixed_point< fixed< Int, Frac, Raw > > |
Test if a type is signed fxd::fixed . More... | |
class | uniform_real_distribution |
Analogous to std::uniform_real_distribution . More... | |
Concepts | |
concept | fixed_point |
Concept to match any fxd::fixed | |
concept | unsigned_fixed_point |
Concept to match only unsigned fxd::fixed | |
concept | signed_fixed_point |
Concept to match only signed fxd::fixed | |
Typedefs | |
template<int Int, int Frac> | |
using | ufixed = fixed< Int, Frac, detail::select_uint_t< Int+Frac > > |
Alias for creating unsigned fxd::fixed . | |
Enumerations | |
enum class | error { underflow , overflow , not_a_number } |
Error values reported by fxd::expect function. More... | |
Functions | |
template<fixed_point Dst, fixed_point Src> | |
constexpr Dst | fixed_cast (Src src) noexcept |
Convert a fixed point to a different type of fixed point. | |
template<int Int, int Frac, typename Raw = detail::select_int_t<Int + Frac>, fixed_point Src> | |
constexpr fixed< Int, Frac, Raw > | fixed_cast (Src src) noexcept |
Convert a fixed point to a different type of fixed point. | |
template<int Int, int Frac, typename Raw = detail::select_uint_t<Int + Frac>, fixed_point Src> | |
constexpr fixed< Int, Frac, Raw > | ufixed_cast (Src src) noexcept |
Convert a fixed point to a different type of fixed point (unsigned version.) | |
template<fixed_point Fxd> | |
constexpr bool | operator== (Fxd a, Fxd b) noexcept |
Equality check for two similar fxd::fixed . | |
template<fixed_point A, fixed_point B> | |
constexpr bool | operator== (A a, B b) noexcept |
Equality check for dissimilar fxd::fixed . | |
template<fixed_point Fxd, std::integral I> | |
constexpr bool | operator== (Fxd a, I b) noexcept |
fxd::fixed == integer. | |
template<fixed_point Fxd, std::floating_point Flt> requires (requires (Fxd fxd) {to_float(fxd);}) | |
constexpr bool | operator== (Fxd a, Flt b) noexcept |
fxd::fixed == floating-point | |
template<fixed_point Fxd> | |
constexpr std::strong_ordering | operator<=> (Fxd a, Fxd b) noexcept |
template<fixed_point A, fixed_point B> | |
constexpr std::strong_ordering | operator<=> (A a, B b) noexcept |
template<fixed_point Fxd, std::integral I> | |
constexpr std::strong_ordering | operator<=> (Fxd a, I b) noexcept |
template<fixed_point Fxd, std::floating_point Flt> requires (requires (Fxd a) {to_float(a);}) | |
constexpr std::partial_ordering | operator<=> (Fxd a, Flt b) noexcept |
template<std::integral I, fixed_point Fxd> | |
constexpr I | to_int (Fxd f) noexcept |
Convert to integer. | |
template<fixed_point Fxd> requires detail::has_int_for<Fxd::int_bits, typename Fxd::raw_type> | |
constexpr detail::select_int_for< Fxd::int_bits, typename Fxd::raw_type > | to_int (Fxd f) noexcept |
Convert to the "natural integer" for this fixed-point type. | |
template<std::floating_point Flt, fixed_point Fxd> | |
constexpr Flt | to_float (Fxd f) noexcept |
Convert a fixed-point to a floating-point type, rounds to zero. | |
template<fixed_point Fxd> | |
constexpr std::numeric_limits< Fxd >::float_type | to_float (Fxd f) noexcept |
Converts a fixed-point to its natural floating-point type (with no losses/rounding). | |
template<fixed_point Fxd> | |
constexpr Fxd | abs (Fxd f) noexcept |
Same as std::abs() . | |
template<fixed_point Fxd> | |
constexpr Fxd | fdim (Fxd a, Fxd b) noexcept |
Same as std::fdim() . | |
template<fixed_point Fxd> | |
constexpr Fxd | fma (Fxd a, Fxd b, Fxd c) noexcept |
Same as std::fma() . | |
template<fixed_point Fxd> | |
constexpr int | ilogb (Fxd x) noexcept |
Same as std::ilogb() . | |
template<fixed_point Fxd> | |
constexpr Fxd | midpoint (Fxd a, Fxd b) noexcept |
Same as std::midpoint() . | |
template<fixed_point Fxd> | |
constexpr Fxd | nextafter (Fxd from, Fxd to) noexcept |
Same as std::nextafter() . | |
template<unsigned_fixed_point Fxd> requires (Fxd::int_bits > 0 && Fxd::frac_bits >= 0) | |
constexpr Fxd | sqrt (Fxd x) noexcept |
Same as std::sqrt() . | |
template<signed_fixed_point Fxd> requires (Fxd::int_bits > 1 && Fxd::frac_bits >= 0) | |
constexpr Fxd | sqrt (Fxd x) noexcept |
template<unsigned_fixed_point Fxd> requires (Fxd::int_bits > 0 && Fxd::frac_bits >= 0) | |
Fxd | sqrt_bin (Fxd x) noexcept |
template<signed_fixed_point Fxd> requires (Fxd::int_bits > 1 && Fxd::frac_bits >= 0) | |
Fxd | sqrt_bin (Fxd x) noexcept |
template<fixed_point Fxd, std::convertible_to< Fxd > T> | |
constexpr Fxd & | operator+= (Fxd &a, T b) noexcept |
In-place addition. | |
template<fixed_point Fxd, std::convertible_to< Fxd > T> | |
constexpr Fxd & | operator-= (Fxd &a, T b) noexcept |
In-place subtraction. | |
template<fixed_point Fxd, std::convertible_to< Fxd > T> requires (!std::integral<T>) | |
constexpr Fxd & | operator*= (Fxd &a, T b) noexcept |
In-place multiplication. | |
template<fixed_point Fxd, std::integral I> | |
constexpr Fxd & | operator*= (Fxd &a, I b) noexcept |
In-place multiplication by integer. | |
template<fixed_point Fxd, std::convertible_to< Fxd > T> requires (!std::integral<T>) | |
constexpr Fxd & | operator/= (Fxd &a, T b) noexcept |
In-place division. | |
template<fixed_point Fxd, std::integral I> | |
constexpr Fxd & | operator/= (Fxd &a, I b) noexcept |
In-place division by integer. | |
template<fixed_point Fxd> | |
constexpr Fxd & | operator++ (Fxd &a) noexcept |
Pre-increment. | |
template<fixed_point Fxd> | |
constexpr Fxd & | operator-- (Fxd &a) noexcept |
Pre-decrement. | |
template<fixed_point Fxd> | |
constexpr Fxd | operator++ (Fxd &a, int) noexcept |
Post-increment. | |
template<fixed_point Fxd> | |
constexpr Fxd | operator-- (Fxd &a, int) noexcept |
Post-decrement. | |
template<fixed_point Fxd> | |
constexpr Fxd | operator+ (Fxd a) noexcept |
Unary + . | |
template<fixed_point Fxd> | |
constexpr Fxd | operator- (Fxd a) noexcept |
Negation. | |
template<typename A , typename B > requires (fixed_point<A> || fixed_point<B>) | |
constexpr std::common_type_t< A, B > | operator+ (A a, B b) noexcept |
Addition. | |
template<typename A , typename B > requires (fixed_point<A> || fixed_point<B>) | |
constexpr std::common_type_t< A, B > | operator- (A a, B b) noexcept |
Subtraction. | |
template<fixed_point A, fixed_point B> | |
constexpr std::common_type_t< A, B > | operator* (A a, B b) noexcept |
Multiply: fxd::fixed * fxd::fixed | |
template<fixed_point Fxd, std::integral I> | |
constexpr Fxd | operator* (Fxd a, I b) noexcept |
Multiply: fxd::fixed * integer. | |
template<std::integral I, fixed_point Fxd> | |
constexpr Fxd | operator* (I a, Fxd b) noexcept |
Multiply: integer * fxd::fixed | |
template<fixed_point Fxd, std::floating_point Flt> | |
constexpr Fxd | operator* (Fxd a, Flt b) noexcept |
Multiply: fxd::fixed * floating-point | |
template<std::floating_point Flt, fixed_point Fxd> | |
constexpr Fxd | operator* (Flt a, Fxd b) noexcept |
Multiply: floating-point * fxd::fixed | |
template<fixed_point A, fixed_point B> | |
constexpr std::common_type_t< A, B > | operator/ (A a, B b) noexcept |
Divide: fxd::fixed / fxd::fixed | |
template<fixed_point Fxd, std::integral I> | |
constexpr Fxd | operator/ (Fxd a, I b) noexcept |
Divide: fxd::fixed / integer. | |
template<std::integral I, fixed_point Fxd> | |
constexpr Fxd | operator/ (I a, Fxd b) noexcept |
Divide: integer / fxd::fixed | |
template<fixed_point Fxd, std::floating_point Flt> | |
constexpr Fxd | operator/ (Fxd a, Flt b) noexcept |
Divide: fxd::fixed / floating-point | |
template<std::floating_point Flt, fixed_point Fxd> | |
constexpr Fxd | operator/ (Flt a, Fxd b) noexcept |
Divide: floating-point / fxd::fixed . | |
template<typename CharT , typename Traits , fixed_point Fxd> | |
std::basic_ostream< CharT, Traits > & | operator<< (std::basic_ostream< CharT, Traits > &out, Fxd f) |
Output (by converting to a floating-point value). | |
template<typename CharT , typename Traits , fixed_point Fxd> | |
std::basic_istream< CharT, Traits > & | operator>> (std::basic_istream< CharT, Traits > &in, Fxd &f) |
Input (by converting from a floatiung-point value). | |
Variables | |
template<typename T > | |
constexpr bool | is_fixed_point_v = is_fixed_point<T>::value |
Helper template variable for fxd::is_fixed_point | |
template<typename T > | |
constexpr bool | is_signed_fixed_point_v = is_signed_fixed_point<T>::value |
Helper template variable for fxd::is_signed_fixed_point | |
This is the namespace where the entire library is defined.
Alias for creating unsigned fxd::fixed
.
|
strong |
Error values reported by fxd::expect
function.
Enumerator | |
---|---|
underflow | |
overflow | |
not_a_number |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
Convert a fixed point to a different type of fixed point.
Definition at line 28 of file casting.hpp.
|
constexprnoexcept |
Convert a fixed point to a different type of fixed point.
Definition at line 68 of file casting.hpp.
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
Multiply: fxd::fixed
* fxd::fixed
Definition at line 251 of file operators.hpp.
|
constexprnoexcept |
Multiply: floating-point * fxd::fixed
Definition at line 304 of file operators.hpp.
|
constexprnoexcept |
Multiply: fxd::fixed
* floating-point
Definition at line 290 of file operators.hpp.
|
constexprnoexcept |
Multiply: fxd::fixed
* integer.
Definition at line 265 of file operators.hpp.
|
constexprnoexcept |
Multiply: integer * fxd::fixed
Definition at line 278 of file operators.hpp.
|
constexprnoexcept |
In-place multiplication by integer.
Definition at line 92 of file operators.hpp.
|
constexprnoexcept |
In-place multiplication.
Definition at line 79 of file operators.hpp.
|
constexprnoexcept |
Addition.
Definition at line 218 of file operators.hpp.
|
constexprnoexcept |
Unary +
.
Definition at line 194 of file operators.hpp.
|
constexprnoexcept |
Pre-increment.
Definition at line 138 of file operators.hpp.
|
constexprnoexcept |
Post-increment.
Definition at line 162 of file operators.hpp.
|
constexprnoexcept |
In-place addition.
Definition at line 50 of file operators.hpp.
|
constexprnoexcept |
Subtraction.
Definition at line 235 of file operators.hpp.
|
constexprnoexcept |
Negation.
Definition at line 205 of file operators.hpp.
|
constexprnoexcept |
Pre-decrement.
Definition at line 150 of file operators.hpp.
|
constexprnoexcept |
Post-decrement.
Definition at line 175 of file operators.hpp.
|
constexprnoexcept |
In-place subtraction.
Definition at line 64 of file operators.hpp.
|
constexprnoexcept |
Divide: fxd::fixed
/ fxd::fixed
Definition at line 319 of file operators.hpp.
|
constexprnoexcept |
Divide: floating-point / fxd::fixed
.
Definition at line 372 of file operators.hpp.
|
constexprnoexcept |
Divide: fxd::fixed
/ floating-point
Definition at line 359 of file operators.hpp.
|
constexprnoexcept |
Divide: fxd::fixed
/ integer.
Definition at line 333 of file operators.hpp.
|
constexprnoexcept |
Divide: integer / fxd::fixed
Definition at line 346 of file operators.hpp.
|
constexprnoexcept |
In-place division by integer.
Definition at line 120 of file operators.hpp.
|
constexprnoexcept |
In-place division.
Definition at line 107 of file operators.hpp.
std::basic_ostream< CharT, Traits > & operator<< | ( | std::basic_ostream< CharT, Traits > & | out, |
Fxd | f | ||
) |
Output (by converting to a floating-point value).
Definition at line 372 of file operators.hpp.
|
constexprnoexcept |
Definition at line 133 of file compare.hpp.
|
constexprnoexcept |
Definition at line 215 of file compare.hpp.
|
constexprnoexcept |
Definition at line 116 of file compare.hpp.
|
constexprnoexcept |
Definition at line 188 of file compare.hpp.
|
constexprnoexcept |
Equality check for dissimilar fxd::fixed
.
Definition at line 39 of file compare.hpp.
|
constexprnoexcept |
fxd::fixed
== floating-point
Definition at line 104 of file compare.hpp.
|
constexprnoexcept |
Equality check for two similar fxd::fixed
.
Definition at line 25 of file compare.hpp.
|
constexprnoexcept |
fxd::fixed
== integer.
Definition at line 79 of file compare.hpp.
std::basic_istream< CharT, Traits > & operator>> | ( | std::basic_istream< CharT, Traits > & | in, |
Fxd & | f | ||
) |
Input (by converting from a floatiung-point value).
Definition at line 402 of file operators.hpp.
|
constexprnoexcept |
Same as std::sqrt()
.
x
is negative, errno
is set to EDOM
.
|
noexcept |
|
constexprnoexcept |
Convert a fixed-point to a floating-point type, rounds to zero.
Definition at line 98 of file conversions.hpp.
|
constexprnoexcept |
Converts a fixed-point to its natural floating-point type (with no losses/rounding).
Definition at line 112 of file conversions.hpp.
|
constexprnoexcept |
Convert to integer.
Definition at line 45 of file conversions.hpp.
|
constexprnoexcept |
Convert to the "natural integer" for this fixed-point type.
Definition at line 72 of file conversions.hpp.
|
constexprnoexcept |
Convert a fixed point to a different type of fixed point (unsigned version.)
Definition at line 83 of file casting.hpp.
|
inlineconstexpr |
Helper template variable for fxd::is_fixed_point
Definition at line 35 of file traits.hpp.
|
inlineconstexpr |
Helper template variable for fxd::is_signed_fixed_point
Definition at line 51 of file traits.hpp.