|
|
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.
|
|
consteval | FixedPoint (float value) noexcept |
|
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.
|
|
consteval | FixedPoint (double value) noexcept |
| 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 BaseType & | raw () noexcept |
|
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.
|
|
constexpr FixedPoint | MultiplyInt (const std::integral auto &rhs) const |
| | Multiply by an integral type.
|
|
constexpr FixedPoint | DivideInt (const std::integral auto &rhs) const |
| | Divide by an integral type.
|
|
constexpr FixedPoint | operator* (const std::integral auto &rhs) const |
|
constexpr FixedPoint | operator/ (const std::integral auto &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 |