|
constexpr | FixedPoint ()=default |
| Default constructor.
|
|
template<std::size_t OtherFractionalBits> |
constexpr | FixedPoint (FixedPoint< OtherFractionalBits > other) noexcept |
| Construct a fixed point number from another fixed point number.
|
|
template<std::size_t OtherFractionalBits> |
constexpr | operator FixedPoint< OtherFractionalBits > () const |
|
template<std::integral T> |
constexpr | FixedPoint (T value) noexcept |
| Convert an integer to a fixed point number.
|
|
constexpr | FixedPoint (float value) noexcept |
| Convert from a float to a fixed point number.
|
|
template<std::size_t OtherFractionalBits, bool OtherRounded = Rounded, bool OtherApproximating = FastApproximation> |
constexpr | operator FixedPoint< OtherFractionalBits, OtherRounded, OtherApproximating > () const |
|
constexpr | operator float () const noexcept |
| Explicit conversion to float.
|
|
constexpr float | to_float () const noexcept |
| Explicit conversion to float.
|
|
constexpr | FixedPoint (double value) noexcept |
| Convert from a double to a fixed point number.
|
|
constexpr | operator double () const noexcept |
| Explicit conversion to double.
|
|
template<std::size_t OutputFractionalBits> |
constexpr FixedPoint< OutputFractionalBits > | as () const |
| Convert to a fixed point number with a different number of fractional bits.
|
|
template<std::signed_integral T> |
constexpr | operator T () const noexcept |
| Explicit conversion to integer.
|
|
constexpr | operator bool () const noexcept |
|
constexpr FixedPoint | operator- () const |
| Negation operator.
|
|
constexpr BaseType | raw () const noexcept |
| Get the internal value.
|
|
constexpr FixedPoint | operator+ (const FixedPoint &rhs) const |
| Addition operator Add two fixed point numbers with the same number of fractional bits.
|
|
constexpr FixedPoint | operator+= (const FixedPoint &rhs) |
| Addition operator Add two fixed point numbers with the same number of fractional bits.
|
|
constexpr FixedPoint | operator- (const FixedPoint &rhs) const |
| Subtraction operator Subtract two fixed point numbers with the same number of fractional bits.
|
|
constexpr FixedPoint | operator-= (const FixedPoint &rhs) |
| Subtraction operator Subtract two fixed point numbers with the same number of fractional bits.
|
|
constexpr FixedPoint | operator* (const FixedPoint &rhs) const |
| Multiplication operator Multiply two fixed point numbers with the same number of fractional bits.
|
|
constexpr FixedPoint | operator*= (const FixedPoint &rhs) |
| Multiplication operator Multiply two fixed point numbers with the same number of fractional bits.
|
|
template<std::size_t OutputFractionalBits = FractionalBits, std::size_t OtherFractionalBits, bool OtherRounded, bool OtherApproximating>
requires (OtherRounded == Rounded && OtherApproximating == FastApproximation) |
constexpr FixedPoint< OutputFractionalBits, Rounded, FastApproximation > | operator* (const FixedPoint< OtherFractionalBits, OtherRounded, OtherApproximating > &rhs) const |
| Multiplication operator Multiply two fixed point numbers with different number of fractional bits.
|
|
template<std::size_t OtherFractionalBits> |
constexpr FixedPoint | operator*= (const FixedPoint< OtherFractionalBits > &rhs) |
| Multiplication operator Multiply two fixed point numbers with different number of fractional bits.
|
|
constexpr FixedPoint | operator/ (const FixedPoint &rhs) const |
| Division operator Divide two fixed point numbers with the same number of fractional bits.
|
|
template<std::size_t OtherFractionalBits, std::size_t ResultFractionalBits = std::max(FractionalBits, OtherFractionalBits) - std::min(FractionalBits, OtherFractionalBits)>
requires (ResultFractionalBits < std::max(FractionalBits, OtherFractionalBits)) && (ResultFractionalBits > std::min(FractionalBits, OtherFractionalBits)) |
constexpr FixedPoint< ResultFractionalBits, Rounded, FastApproximation > | operator/ (const FixedPoint< OtherFractionalBits > &rhs) const |
| Division operator Divide two fixed point numbers with different number of fractional bits.
|
|
constexpr FixedPoint | operator/= (const FixedPoint &rhs) |
| Division operator Divide two fixed point numbers with the same number of fractional bits.
|
|
template<std::size_t OtherFractionalBitsA, std::size_t OtherFractionalBitsB> |
constexpr FixedPoint | MultiplyAdd (const FixedPoint< OtherFractionalBitsA > &a, const FixedPoint< OtherFractionalBitsB > &b) const |
| Fused multiply-add operation for fixed point numbers with a different number of fractional bits.
|
|
constexpr FixedPoint | MultiplyAdd (const FixedPoint &a, const FixedPoint &b) const |
| Fused multiply-add operation for fixed point numbers with the same number of fractional bits.
|
|
constexpr bool | operator== (const FixedPoint &rhs) const noexcept |
| Equality operator.
|
|
constexpr std::strong_ordering | operator<=> (const FixedPoint &rhs) const noexcept |
| Three-way comparison operator.
|
|
template<std::size_t OtherFractionalBits> |
constexpr bool | operator== (const FixedPoint< OtherFractionalBits > &rhs) const noexcept |
| Equality operator for fixed point numbers with different number of fractional bits.
|
|
template<std::size_t OtherFractionalBits> |
constexpr std::strong_ordering | operator<=> (const FixedPoint< OtherFractionalBits > &rhs) const noexcept |
| Three-way comparison operator for fixed point numbers with different number of fractional bits.
|
|
template<typename T>
requires std::floating_point<T> |
constexpr bool | operator== (const T &rhs) const noexcept |
| Equality operator for integers and floating point numbers.
|
|
template<std::integral T> |
constexpr FixedPoint | MultiplyInt (const T &rhs) const |
| Multiply by an integral type.
|
|
template<std::integral T> |
constexpr FixedPoint | DivideInt (const T &rhs) const |
| Divide by an integral type.
|
|
template<std::integral T> |
constexpr FixedPoint | operator* (const T &rhs) const |
|
template<std::integral T> |
constexpr FixedPoint | operator/ (const T &rhs) |
|
constexpr int32_t | integral () const |
|
constexpr FixedPoint | absolute () const noexcept |
|
template<std::size_t FractionalBits, bool Rounded = false, bool FastApproximation = (FractionalBits == 31 && ARMv7a)>
class FixedPoint< FractionalBits, Rounded, FastApproximation >
Fixed point number with a configurable number of fractional bits.
- Note
- This class only supports 32-bit signed fixed point numbers
- Template Parameters
-
FractionalBits | The number of fractional bits |
Rounded | Whether to round the result when performing operations |
FastApproximation | Whether to use a fast approximation for operations |