libfxd 0.2.dev
A fixed-point library for C++.
Loading...
Searching...
No Matches
operators.hpp File Reference
#include <compare>
#include <concepts>
#include <ostream>
#include <istream>
#include "concepts.hpp"
#include "limits.hpp"
#include "round-div.hpp"
#include "round-mul.hpp"
#include "traits.hpp"

Go to the source code of this file.

Namespaces

namespace  fxd
 This is the namespace where the entire library is defined.
 

Functions

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).