libfxd 0.2.dev
A fixed-point library for C++.
|
Throw on overflow. More...
Namespaces | |
namespace | down |
Round down, and throw on overflow. | |
namespace | up |
Round up, and throw on overflow. | |
namespace | zero |
Round to zero, and throw on overflow. | |
Functions | |
void | except (error e) |
Error handler that throws exceptions on error. | |
template<fixed_point Fxd, std::integral I> | |
constexpr Fxd | from_raw (I val) |
Construct from raw value, throw on overflow. | |
template<fixed_point Dst, std::convertible_to< Dst > Src> | |
constexpr Dst | make_fixed (Src src) |
Construct from numerical value, throw on overflow. | |
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) |
Convenience overload. | |
template<int Int, int Frac, typename Raw = detail::select_uint_t<Int + Frac>, std::convertible_to< fixed< Int, Frac, Raw > > Src> | |
constexpr fixed< Int, Frac, Raw > | make_ufixed (Src src) |
Convenience overload (unsigned version). | |
template<fixed_point Dst, fixed_point Src> | |
constexpr Dst | fixed_cast (Src src) |
Convert between fxd::fixed types, throw 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) |
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) |
Convenience overload (unsigned version). | |
template<std::integral I, fixed_point Fxd> | |
I | to_int (Fxd f) |
Convert to integer, throw 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, throw on overflow. | |
template<fixed_point Dst, std::convertible_to< Dst > Src> | |
constexpr Dst & | assign (Dst &dst, Src src) |
Assignment, throw on overflow. | |
template<fixed_point Fxd> | |
constexpr Fxd & | pre_inc (Fxd &f) |
Pre-increment (++f ), throw on overflow. | |
template<fixed_point Fxd> | |
constexpr Fxd | post_inc (Fxd &f) |
Post-increment (f++ ), throw on overflow. | |
template<fixed_point Fxd> | |
constexpr Fxd & | pre_dec (Fxd &f) |
Pre-decrement (--f ), throw on overflow. | |
template<fixed_point Fxd> | |
constexpr Fxd | post_dec (Fxd &f) |
Post-decrement (f-- ), throw on overflow. | |
template<fixed_point Fxd> | |
constexpr Fxd | negate (Fxd f) |
Negate, throw on overflow. | |
template<fixed_point Fxd> | |
constexpr Fxd | add (Fxd a, Fxd b) |
Add, throw on overflow. | |
template<fixed_point Fxd> | |
constexpr Fxd | sub (Fxd a, Fxd b) |
Subtract, throw on overflow. | |
template<fixed_point Fxd> | |
constexpr Fxd | div (Fxd a, Fxd b) |
Divide rounding to zero, throw on overflow. | |
template<fixed_point Fxd> | |
constexpr Fxd | mul (Fxd a, Fxd b) |
Multiply rounding to zero, throw on overflow. | |
template<fixed_point Fxd> | |
constexpr Fxd | abs (Fxd f) |
Same as fxd::abs() , throw on overflow. | |
Throw on overflow.
|
constexpr |
Same as fxd::abs()
, throw on overflow.
Definition at line 354 of file except.hpp.
|
constexpr |
|
constexpr |
Assignment, throw on overflow.
Definition at line 179 of file except.hpp.
|
inline |
Error handler that throws exceptions on error.
All functions in fxd::except
use this as an error handler. Possible exceptions are:
std::underflow_error
on underflows; std::overflow_error
on overflows; std::invalid_argument
when NaN
would be generated; Definition at line 39 of file except.hpp.
|
constexpr |
Convert between fxd::fixed
types, throw on overflow.
Definition at line 121 of file except.hpp.
|
constexpr |
Convenience overload.
Definition at line 133 of file except.hpp.
|
constexpr |
Construct from raw value, throw on overflow.
Overflow happens if the represented value does not convert back to the argument's value.
Definition at line 73 of file except.hpp.
|
constexpr |
Construct from numerical value, throw on overflow.
Definition at line 84 of file except.hpp.
|
constexpr |
Convenience overload.
Definition at line 96 of file except.hpp.
|
constexpr |
Convenience overload (unsigned version).
Definition at line 109 of file except.hpp.
|
constexpr |
Negate, throw on overflow.
Definition at line 240 of file except.hpp.
|
constexpr |
Post-decrement (f--
), throw on overflow.
Definition at line 228 of file except.hpp.
|
constexpr |
Post-increment (f++
), throw on overflow.
Definition at line 203 of file except.hpp.
|
constexpr |
Pre-decrement (--f
), throw on overflow.
Definition at line 215 of file except.hpp.
|
constexpr |
Pre-increment (++f
), throw on overflow.
Definition at line 190 of file except.hpp.
|
constexpr |
I to_int | ( | Fxd | f | ) |
Convert to integer, throw on overflow.
Definition at line 157 of file except.hpp.
|
constexpr |
Convert to the natural integer type, throw on overflow.
Definition at line 167 of file except.hpp.
|
constexpr |
Convenience overload (unsigned version).
Definition at line 146 of file except.hpp.