Classes and Functions
-
template<typename FixedType>
struct fixed_hash - #include <fixed.hpp>
The default hash function for fixed point type.
- Template Parameters:
FixedType – fixed point type.
-
template<typename Type, typename IntermediateType, unsigned int fraction, bool rounding = false>
class fixed_num - #include <fixed.hpp>
The fixed number.
- Template Parameters:
Type – the store type.
IntermediateType – used for calculation, must be larger than the store type.
fraction – the fraction part of the fixed number.
rounding – should round the fixed number, default false.
Public Functions
-
inline fixed_num() noexcept = default
-
template<std::integral T>
inline explicit EIRIN_ALWAYS_INLINE constexpr fixed_num(T val) noexcept Construct the fixed number from a integer value.
- Template Parameters:
T – integral type.
- Parameters:
val – the input integer.
- Returns:
EIRIN_ALWAYS_INLINE constexpr the fixed number converted from the integer.
-
template<std::floating_point T>
inline explicit EIRIN_ALWAYS_INLINE constexpr fixed_num(T val) noexcept
-
template<typename T, typename I, unsigned int f, bool r>
inline explicit EIRIN_ALWAYS_INLINE constexpr fixed_num(fixed_num<T, I, f, r> fp) noexcept
- inline EIRIN_ALWAYS_INLINE constexpr Type internal_value () const noexcept
Get the inner value of the fixed number.
Note
do not use unless you know what this function is and what are u doing.
- inline EIRIN_ALWAYS_INLINE constexpr Type raw_integral_part () const noexcept
- inline EIRIN_ALWAYS_INLINE constexpr Type integral_part () const noexcept
- inline EIRIN_ALWAYS_INLINE constexpr Type fractional_part () const noexcept
- template<typename CharT, class Traits> inline EIRIN_ALWAYS_INLINE std::basic_ostream< CharT, Traits > & print (std::basic_ostream< CharT, Traits > &os) const noexcept
- inline EIRIN_ALWAYS_INLINE constexpr fixed_num divide (const std::integral auto &val) const
- inline EIRIN_ALWAYS_INLINE constexpr fixed_num divide (const fixed_num &other) const
- inline EIRIN_ALWAYS_INLINE constexpr fixed_num & divide_by (const std::integral auto &val)
- inline EIRIN_ALWAYS_INLINE constexpr fixed_num & divide_by (const fixed_num &other)
Public Static Functions
- static inline EIRIN_ALWAYS_INLINE constexpr Type signbit_mask () noexcept
- template<unsigned int _fraction, typename T, typename std::enable_if_t<(_fraction > fraction), T * > = nullptr> static inline EIRIN_ALWAYS_INLINE constexpr fixed_num from_fixed_num_value (T inner_value) noexcept
- template<unsigned int _fraction, typename T, typename std::enable_if_t<(_fraction<=fraction), T * > = nullptr> static inline EIRIN_ALWAYS_INLINE constexpr fixed_num from_fixed_num_value (T inner_value) noexcept
Public Static Attributes
-
static constexpr auto sqrt_init_table = detail::sqrt_lookup_table<Type, fraction>::generate()
Private Static Attributes
-
static constexpr IntermediateType fraction_multiplier = IntermediateType(1) << fraction
-
template<typename T, typename I, unsigned int F, bool R, typename CharT>
class formatter<eirin::fixed_num<T, I, F, R>, CharT> : public std_formatter_base Public Functions
-
template<typename ParseContext>
inline auto parse(ParseContext &ctx) -> typename ParseContext::iterator
-
template<typename FormatContext>
inline auto format(const eirin::fixed_num<T, I, F, R> &fp, FormatContext &ctx) const -> typename FormatContext::iterator
Private Types
-
using my_base = std_formatter_base
Private Functions
-
template<typename ParseContext>
-
template<typename T, typename I, unsigned int f, bool r>
struct is_fixed_point<fixed_num<T, I, f, r>> : public std::true_type
-
template<typename T, typename I, unsigned int f, bool r>
struct numeric_limits<eirin::fixed_num<T, I, f, r>> -
Public Static Functions
-
static inline constexpr fixed_type min() noexcept
-
static inline constexpr fixed_type max() noexcept
-
static inline constexpr fixed_type lowest() noexcept
Public Static Attributes
-
static constexpr bool is_specialized = true
-
static constexpr bool is_signed = true
-
static constexpr bool is_integer = false
-
static constexpr bool is_exact = true
-
static constexpr bool has_infinity = false
-
static constexpr bool has_quiet_NaN = false
-
static constexpr bool has_signaling_NaN = false
-
static constexpr fixed_type radix = fixed_type(2)
-
static constexpr fixed_type digits = fixed_type(sizeof(T) * 8 - 1)
-
static constexpr fixed_type digits10 = fixed_type(static_cast<T>((sizeof(T) * 8 - 1) * 643L / 2136))
-
static constexpr fixed_type min_exponent = fixed_type(0)
-
static constexpr fixed_type min_exponent10 = fixed_type(10)
-
static constexpr float_denorm_style has_denorm = denorm_absent
-
static constexpr bool has_denorm_loss = false
-
static constexpr bool is_iec559 = false
-
static constexpr bool is_bounded = true
-
static constexpr bool is_modulo = false
-
static constexpr bool traps = true
-
static constexpr bool tinyness_before = false
-
static constexpr float_round_style round_style = round_toward_zero
-
static inline constexpr fixed_type min() noexcept
-
struct raw_value_construct_tag
-
template<typename T, unsigned int F, int E>
struct sqrt_init_value
-
template<typename T, unsigned int F, typename S = std::make_index_sequence<sizeof(T) * 8>>
struct sqrt_lookup_table
-
template<typename T, unsigned int F, size_t... I>
struct sqrt_lookup_table<T, F, std::index_sequence<I...>>
-
template<int scale>
concept fixed_format_check_scale
-
template<typename Type, typename IntermediateType, unsigned int fraction>
concept fixed_num_check
-
template<typename Type, unsigned int fraction>
concept fixed_num_fraction
-
template<typename Type, typename IntermediateType>
concept fixed_num_signness
-
template<typename Type, typename IntermediateType>
concept fixed_num_size
-
template<typename T>
concept fixed_point
-
namespace eirin
Typedefs
Functions
-
template<typename T, typename I, unsigned int f, bool r>
inline constexpr fixed_num<T, I, f, r> operator+(const fixed_num<T, I, f, r> &fp, const std::integral auto &val) noexcept
-
template<typename T, typename I, unsigned int f, bool r>
inline constexpr fixed_num<T, I, f, r> operator+(const std::integral auto &val, const fixed_num<T, I, f, r> &fp) noexcept
-
template<typename T, typename I, unsigned int f, bool r>
inline constexpr fixed_num<T, I, f, r> operator-(const fixed_num<T, I, f, r> &fp, const std::integral auto &val) noexcept
-
template<typename T, typename I, unsigned int f, bool r>
inline constexpr fixed_num<T, I, f, r> operator-(const std::integral auto &val, const fixed_num<T, I, f, r> &fp) noexcept
-
template<typename T, typename I, unsigned int f, bool r>
inline constexpr fixed_num<T, I, f, r> operator*(const fixed_num<T, I, f, r> &fp, const std::integral auto &val) noexcept
-
template<typename T, typename I, unsigned int f, bool r>
inline constexpr fixed_num<T, I, f, r> operator*(const std::integral auto &val, const fixed_num<T, I, f, r> &fp) noexcept
-
template<typename T, typename I, unsigned int f, bool r>
inline constexpr fixed_num<T, I, f, r> operator/(const fixed_num<T, I, f, r> &fp, const std::integral auto &val)
-
template<typename T, typename I, unsigned int f, bool r>
inline constexpr fixed_num<T, I, f, r> operator/(const std::integral auto &val, const fixed_num<T, I, f, r> &fp)
-
template<typename T, typename I, unsigned int f, bool r>
inline constexpr fixed_num<T, I, f, r> operator%(const fixed_num<T, I, f, r> &fp, const std::integral auto &val) noexcept
-
template<typename T, typename I, unsigned int f, bool r>
inline constexpr fixed_num<T, I, f, r> operator%(const std::integral auto &val, const fixed_num<T, I, f, r> &fp) noexcept
-
template<typename CharT, class Traits, typename T, typename I, unsigned int F, bool R>
std::basic_ostream<CharT, Traits> &operator<<(std::basic_ostream<CharT, Traits> &os, const fixed_num<T, I, F, R> &fp) noexcept
-
template<typename T, typename I, unsigned int f, bool r>
constexpr bool fixed_from_cstring(const char *str, size_t len, fixed_num<T, I, f, r> &fp) noexcept
-
template<typename CharT, class Traits, typename T, typename I, unsigned int f, bool r>
std::basic_istream<CharT, Traits> &operator>>(std::basic_istream<CharT, Traits> &is, fixed_num<T, I, f, r> &fp) noexcept
- template<fixed_point T> EIRIN_ALWAYS_INLINE constexpr T max_value () noexcept
- template<fixed_point T> EIRIN_ALWAYS_INLINE constexpr T min_value () noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > ceil (fixed_num< T, I, f, r > fp) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > floor (fixed_num< T, I, f, r > fp) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > trunc (fixed_num< T, I, f, r > fp) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > round (fixed_num< T, I, f, r > fp) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > abs (fixed_num< T, I, f, r > fp) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > min (fixed_num< T, I, f, r > a, fixed_num< T, I, f, r > b) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > max (fixed_num< T, I, f, r > a, fixed_num< T, I, f, r > b) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > sqrt (fixed_num< T, I, f, r > fp) noexcept
- template<typename T, typename I, unsigned int f, bool r, fixed_num<T, I, f, r> pi = numbers::pi_v<fixed_num<T, I, f, r>>()> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > sin (fixed_num< T, I, f, r > fp) noexcept
sine function for fixed point number.
See also
See also
See also
See also
- Template Parameters:
T –
I –
f –
r –
pi – the pi value, default is pi_v<fixed_num<T, I, f, r>>(). if you want more precision for fixed types like fixed128, you can pass the value you want.
- Parameters:
fp –
- Returns:
sin(fp)
- template<typename T, typename I, unsigned int f, bool r, fixed_num<T, I, f, r> pi = numbers::pi_v<fixed_num<T, I, f, r>>()> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > cos (fixed_num< T, I, f, r > fp) noexcept
cosine function for fixed point number.
- Template Parameters:
T –
I –
f –
r –
pi – the pi value, default is pi_v<fixed_num<T, I, f, r>>(). if you want more precision for fixed types like fixed128, you can pass the value you want.
- Parameters:
fp –
- Returns:
cos(fp)
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > tan (fixed_num< T, I, f, r > fp)
- template<typename T, typename I, unsigned int f, bool r, fixed_num<T, I, f, r> pi = numbers::pi_v<fixed_num<T, I, f, r>>()> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > atan (fixed_num< T, I, f, r > fp) noexcept
Arctangent function for fixed point number, using the fitting method from the paper “Efficient Approximations for the Arctangent Function”.
See also
See also
See also
See also
Note
reference paper: https://ieeexplore.ieee.org/document/1628884
- Template Parameters:
T –
I –
f –
r –
pi – the pi value, default is pi_v<fixed_num<T, I, f, r>>(). if you want more precision for fixed types like fixed128, you can pass the value you want.
- Parameters:
fp – the x of atan(x)
- Returns:
atan(x).
- template<typename T, typename I, unsigned int f, bool r, fixed_num<T, I, f, r> pi = numbers::pi_v<fixed_num<T, I, f, r>>()> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > asin (fixed_num< T, I, f, r > fp)
- template<typename T, typename I, unsigned int f, bool r, fixed_num<T, I, f, r> pi = numbers::pi_v<fixed_num<T, I, f, r>>()> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > acos (fixed_num< T, I, f, r > fp)
- template<typename T, typename I, unsigned int f, bool r, int iter_max = 200> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > cbrt (fixed_num< T, I, f, r > fp) noexcept
cbrt function for fixed point number, which used newton method to calculate the cbrt.
See also
See also
See also
See also
- Template Parameters:
T –
I –
f –
r –
iter_max – max iteration times, default is 200.
- Parameters:
fp –
- Returns:
cbrt(fp)
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > log2 (fixed_num< T, I, f, r > fp)
log2 function for fixed point number, which used some bit hacks.
See also
See also
See also
See also
- Template Parameters:
T –
I –
f –
r –
- Parameters:
fp –
- Returns:
log2(fp)
- template<typename T, typename I, unsigned int f, bool r, fixed_num<T, I, f, r> log2_e = fixed_num<T, I, f, r>::template from_fixed_num_value<60>(0x171547652B82FE00ll)> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > log (fixed_num< T, I, f, r > fp)
ln function for fixed point number, which used the log2 function to calculate the ln.
See also
See also
See also
See also
- Template Parameters:
T –
I –
f –
r –
log2_e – the log2(e) value, and its default value is designed for 32bit and 64bit fixed number. if you want more precision for fixed types like fixed128, you can pass the value you want.
- Parameters:
fp –
- Returns:
log(fp)
- template<typename T, typename I, unsigned int f, bool r, fixed_num<T, I, f, r> log2_10 = fixed_num<T, I, f, r>::template from_fixed_num_value<60>(0x35269E12F346E200ll)> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > log10 (fixed_num< T, I, f, r > fp)
the log10 function for fixed point number, which used the log2 function to calculate the log10.
See also
See also
See also
See also
- Template Parameters:
T –
I –
f –
r –
log2_10 – the log2(10) value, and its default value is designed for 32bit and 64bit fixed number. if you want more precision for fixed types like fixed128, you can pass the value you want.
- Parameters:
fp –
- Returns:
log10(fp)
- template<typename T, typename I, unsigned int f, bool r, std::integral E> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > pow (fixed_num< T, I, f, r > b, E e) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > exp (fixed_num< T, I, f, r > fp) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > pow (fixed_num< T, I, f, r > b, fixed_num< T, I, f, r > e) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > fmod (fixed_num< T, I, f, r > a, fixed_num< T, I, f, r > b) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > modf (fixed_num< T, I, f, r > fp, fixed_num< T, I, f, r > &int_part) noexcept
- template<typename T, typename I, unsigned int f, bool r, fixed_num<T, I, f, r> pi = eirin::numbers::pi_v<fixed_num<T, I, f, r>>()> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > degrees (fixed_num< T, I, f, r > rad) noexcept
convert radian to degree.
See also
See also
See also
See also
- Template Parameters:
T –
I –
f –
r –
pi – the pi value, default is pi_v<fixed_num<T, I, f, r>>(). if you want more precision for fixed types like fixed128, you can pass the value you want.
- Parameters:
rad –
- Returns:
deg(rad)
- template<typename T, typename I, unsigned int f, bool r, fixed_num<T, I, f, r> pi = eirin::numbers::pi_v<fixed_num<T, I, f, r>>()> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > radians (fixed_num< T, I, f, r > deg) noexcept
convert degree to radian.
See also
See also
See also
See also
- Template Parameters:
T –
I –
f –
r –
pi – the pi value, default is pi_v<fixed_num<T, I, f, r>>(). if you want more precision for fixed types like fixed128, you can pass the value you want.
- Parameters:
deg –
- Returns:
rad(deg)
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > hypot (fixed_num< T, I, f, r > x, fixed_num< T, I, f, r > y) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > hypot (fixed_num< T, I, f, r > x, fixed_num< T, I, f, r > y, fixed_num< T, I, f, r > z) noexcept
-
template<typename T, typename I, unsigned int f, bool r>
-
namespace detail
Functions
-
template<typename CharT, typename T, typename I, unsigned int f, bool r>
constexpr bool parse(const CharT *str, size_t len, fixed_num<T, I, f, r> &fp) noexcept
- template<typename T, typename I, unsigned int f, bool r> EIRIN_ALWAYS_INLINE constexpr fixed_num< T, I, f, r > exp_expand (fixed_num< T, I, f, r > fp) noexcept
-
template<typename CharT, typename T, typename I, unsigned int f, bool r>
-
namespace literals
-
namespace papilio
-
namespace std
- file papilio_integration.hpp
- #include <papilio/core.hpp>#include “../fixed.hpp”
- file fixed.hpp
- #include <array>#include <cassert>#include <cctype>#include <cstddef>#include <cstdint>#include <cstdio>#include <cstring>#include <ios>#include <limits>#include <istream>#include <stdexcept>#include <type_traits>#include <concepts>#include <iostream>#include <algorithm>#include <eirin/detail/int128.hpp>#include <eirin/macro.hpp>
- file math.hpp
- #include <eirin/fixed.hpp>#include <stdexcept>#include <eirin/numbers.hpp>
- file parse.hpp
- #include <string_view>#include “fixed.hpp”
- dir /home/docs/checkouts/readthedocs.org/user_builds/eirinfixed/checkouts/latest/include/eirin
- dir /home/docs/checkouts/readthedocs.org/user_builds/eirinfixed/checkouts/latest/include/eirin/ext
- dir /home/docs/checkouts/readthedocs.org/user_builds/eirinfixed/checkouts/latest/include