|
libfxd 0.2.dev
A fixed-point library for C++.
|
Clamp on overflow. More...
Namespaces | |
| namespace | down |
| Round down, and clamp on overflow. | |
| namespace | up |
| Round up, and clamp on overflow. | |
| namespace | zero |
| Round to zero, and clamp on overflow. | |
Functions | |
| template<typename T > | |
| constexpr T | saturate (error e) noexcept |
| Error handler that clamps the value on error. | |
| template<fixed_point Fxd, std::integral I> | |
| constexpr Fxd | from_raw (I val) noexcept |
| Construct from raw value, clamp on overflow. | |
| template<fixed_point Dst, std::convertible_to< Dst > Src> | |
| constexpr Dst | make_fixed (Src src) noexcept |
| Construct from numerical value, clamp on overflow. | |
| template<unsigned_fixed_point Dst, std::convertible_to< Dst > Src> | |
| constexpr Dst | make_ufixed (Src src) noexcept |
| Construct from numerical value, clamp on overflow (unsigned version). | |
| template<int Int, int Frac, typename Raw = detail::select_int_t<Int + Frac>, std::convertible_to< fixed< Int, Frac, Raw > > Src> | |
| constexpr fixed< Int, Frac, Raw > | make_fixed (Src src) noexcept |
| Convenience overload. | |
| template<fixed_point Dst, fixed_point Src> | |
| constexpr Dst | fixed_cast (Src src) noexcept |
Convert between fxd::fixed types, clamp on overflow. | |
| 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 |
| Convenience overload. | |
| 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 |
| Convenience overload (unsigned version). | |
| template<std::integral I, fixed_point Fxd> | |
| constexpr I | to_int (Fxd f) noexcept |
| Convert to integer, clamp on overflow. | |
| template<fixed_point Fxd> | |
| constexpr detail::select_int_for< Fxd::int_bits, typename Fxd::raw_type > | to_int (Fxd f) |
| Convert to the natural integer type, clamp on overflow. | |
| template<fixed_point Dst, std::convertible_to< Dst > Src> | |
| constexpr Dst & | assign (Dst &dst, Src src) noexcept |
| Assignment, clamp on overflow. | |
| template<fixed_point Fxd> | |
| constexpr Fxd & | pre_inc (Fxd &f) noexcept |
Pre-increment (++f), clamp on overflow. | |
| template<fixed_point Fxd> | |
| constexpr Fxd | post_inc (Fxd &f) noexcept |
Post-increment (f++), clamp on overflow. | |
| template<fixed_point Fxd> | |
| constexpr Fxd & | pre_dec (Fxd &f) noexcept |
Pre-decrement (--f), clamp on overflow. | |
| template<fixed_point Fxd> | |
| constexpr Fxd | post_dec (Fxd &f) noexcept |
Post-decrement (f--), clamp on overflow. | |
| template<fixed_point Fxd> | |
| constexpr Fxd | negate (Fxd f) noexcept |
| Negate, clamp on overflow. | |
| template<fixed_point Fxd> | |
| constexpr Fxd | add (Fxd a, Fxd b) noexcept |
| Add, clamp on overflow. | |
| template<fixed_point Fxd> | |
| constexpr Fxd | sub (Fxd a, Fxd b) noexcept |
| Subtract, clamp on overflow. | |
| template<fixed_point Fxd> | |
| constexpr Fxd | div (Fxd a, Fxd b) noexcept |
| Divide rounding to zero, clamp on overflow. | |
| template<fixed_point Fxd> | |
| constexpr Fxd | mul (Fxd a, Fxd b) noexcept |
| Multiply rounding to zero, clamp on overflow. | |
| template<fixed_point Fxd> | |
| constexpr Fxd | abs (Fxd f) noexcept |
Same as fxd::abs(), clamp on overflow. | |
Clamp on overflow.
|
constexprnoexcept |
Same as fxd::abs(), clamp on overflow.
Definition at line 394 of file saturate.hpp.
|
constexprnoexcept |
Add, clamp on overflow.
Definition at line 275 of file saturate.hpp.
|
constexprnoexcept |
Assignment, clamp on overflow.
Definition at line 196 of file saturate.hpp.
|
constexprnoexcept |
Convert between fxd::fixed types, clamp on overflow.
Definition at line 129 of file saturate.hpp.
|
constexprnoexcept |
Convenience overload.
Definition at line 143 of file saturate.hpp.
|
constexprnoexcept |
Construct from raw value, clamp on overflow.
Overflow happens if the represented value does not convert back to the argument's value.
Definition at line 75 of file saturate.hpp.
|
constexprnoexcept |
Construct from numerical value, clamp on overflow.
Definition at line 88 of file saturate.hpp.
|
constexprnoexcept |
Convenience overload.
Definition at line 115 of file saturate.hpp.
|
constexprnoexcept |
Construct from numerical value, clamp on overflow (unsigned version).
Definition at line 101 of file saturate.hpp.
|
constexprnoexcept |
Negate, clamp on overflow.
Definition at line 263 of file saturate.hpp.
|
constexprnoexcept |
Post-decrement (f--), clamp on overflow.
Definition at line 249 of file saturate.hpp.
|
constexprnoexcept |
Post-increment (f++), clamp on overflow.
Definition at line 222 of file saturate.hpp.
|
constexprnoexcept |
Pre-decrement (--f), clamp on overflow.
Definition at line 235 of file saturate.hpp.
|
constexprnoexcept |
Pre-increment (++f), clamp on overflow.
Definition at line 208 of file saturate.hpp.
|
constexprnoexcept |
Error handler that clamps the value on error.
The returned value will always be clamped between std::numeric_limits<T>::lowest() and std::numeric_limits<T>::max() when it makes sense. The operation 0/0 will not return a value, it will raise the SIGFPE signal.
Definition at line 38 of file saturate.hpp.
|
constexprnoexcept |
Subtract, clamp on overflow.
Definition at line 288 of file saturate.hpp.
|
constexpr |
Convert to the natural integer type, clamp on overflow.
Definition at line 184 of file saturate.hpp.
|
constexprnoexcept |
Convert to integer, clamp on overflow.
Definition at line 172 of file saturate.hpp.
|
constexprnoexcept |
Convenience overload (unsigned version).
Definition at line 158 of file saturate.hpp.