Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
Loading...
Searching...
No Matches
efloat_impl.hpp File Reference
#include <algorithm>
#include <array>
#include <bit>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <ios>
#include <limits>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <vector>
#include <universal/utility/exceptions_check.hpp>
#include <universal/native/ieee754_core.hpp>
#include <universal/native/manipulators_core.hpp>
#include <universal/number/shared/specific_value_encoding.hpp>
#include <universal/utility/string_parse.hpp>
#include <universal/utility/decimal_to_binary.hpp>
#include <universal/number/efloat/exceptions.hpp>
#include <universal/internal/limbs/limb_kernels.hpp>
#include <universal/number/efloat/efloat_limbs.hpp>
#include <universal/number/efloat/double_math.hpp>
#include <universal/behavior/rounding.hpp>
#include <universal/behavior/status_flags.hpp>

Classes

class  sw::universal::efloat< nlimbs >
struct  sw::universal::efloat< nlimbs >::uninitialized_t
struct  sw::universal::efloat< nlimbs >::native_limbs
struct  sw::universal::efloat< nlimbs >::native_rounding

Namespaces

namespace  sw
 required std libraries
namespace  sw::universal
namespace  sw::universal::efloat_parse_detail
 string parsing
namespace  sw::universal::efloat_detail
 decimal formatting (binary -> decimal string at arbitrary precision)

Macros

#define EFLOAT_ENABLE_LITERALS   1
 BEHAVIORAL COMPILATION SWITCHES.
#define EFLOAT_THROW_ARITHMETIC_EXCEPTION   0
#define EFLOAT_INLINE_LIMBS   8

Enumerations

enum class  sw::universal::FloatingPointState {
  sw::universal::Zero , sw::universal::Normal , sw::universal::SignalingNaN , sw::universal::QuietNaN ,
  sw::universal::Infinite
}
enum class  sw::universal::efloat_parse_detail::parse_outcome { sw::universal::efloat_parse_detail::done , sw::universal::efloat_parse_detail::undecided , sw::universal::efloat_parse_detail::refused }

Functions

unsigned sw::universal::get_default_precision () noexcept
void sw::universal::set_default_precision (unsigned bits) noexcept
static constexpr int sw::universal::clz (uint32_t x) noexcept
constexpr std::size_t sw::universal::efloat_inline_limbs (unsigned nlimbs) noexcept
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::abs (const efloat< nlimbs > &a)
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::fabs (const efloat< nlimbs > &a)
template<std::size_t N, unsigned nlimbs>
constexpr std::array< double, N > sw::universal::to_double_expansion (const efloat< nlimbs > &v)
template<unsigned W, unsigned nlimbs>
constexpr parse_outcome sw::universal::efloat_parse_detail::round_into (const sw::universal::string_parse::decimal_float_scan &d, unsigned target_bits, bool inexact, efloat< nlimbs > &value)
constexpr bool sw::universal::efloat_parse_detail::is_space (char c) noexcept
constexpr char sw::universal::efloat_parse_detail::to_lower (char c) noexcept
constexpr void sw::universal::efloat_parse_detail::append_decimal (std::string &text, std::int64_t e)
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::efloat_parse_detail::power_of_ten (std::uint64_t n, unsigned bits)
constexpr bool sw::universal::efloat_parse_detail::read_exponent (std::string_view s, std::int64_t &e) noexcept
template<unsigned nlimbs>
constexpr void sw::universal::efloat_parse_detail::scale_by_power_of_ten (std::string_view digits, std::int64_t exp10, bool negative, unsigned target_bits, efloat< nlimbs > &value)
template<unsigned BigBits = sw::universal::decimal_to_binary::default_big_bits, unsigned nlimbs>
constexpr bool sw::universal::parse (std::string_view number, efloat< nlimbs > &v)
template<unsigned nlimbs>
std::string sw::universal::to_string (const efloat< nlimbs > &value, std::streamsize precision, std::streamsize width, bool fixed, bool scientific, bool internal, bool left, bool showpos, bool uppercase, char fill)
template<unsigned nlimbs>
constexpr bool sw::universal::operator== (const efloat< nlimbs > &lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr bool sw::universal::operator!= (const efloat< nlimbs > &lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr bool sw::universal::operator< (const efloat< nlimbs > &lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr bool sw::universal::operator> (const efloat< nlimbs > &lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr bool sw::universal::operator<= (const efloat< nlimbs > &lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr bool sw::universal::operator>= (const efloat< nlimbs > &lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr bool sw::universal::operator== (const efloat< nlimbs > &lhs, double rhs)
template<unsigned nlimbs>
constexpr bool sw::universal::operator!= (const efloat< nlimbs > &lhs, double rhs)
template<unsigned nlimbs>
constexpr bool sw::universal::operator< (const efloat< nlimbs > &lhs, double rhs)
template<unsigned nlimbs>
constexpr bool sw::universal::operator> (const efloat< nlimbs > &lhs, double rhs)
template<unsigned nlimbs>
constexpr bool sw::universal::operator<= (const efloat< nlimbs > &lhs, double rhs)
template<unsigned nlimbs>
constexpr bool sw::universal::operator>= (const efloat< nlimbs > &lhs, double rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator== (const efloat< nlimbs > &lhs, Integer rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator!= (const efloat< nlimbs > &lhs, Integer rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator< (const efloat< nlimbs > &lhs, Integer rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator> (const efloat< nlimbs > &lhs, Integer rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator<= (const efloat< nlimbs > &lhs, Integer rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator>= (const efloat< nlimbs > &lhs, Integer rhs)
template<unsigned nlimbs>
constexpr bool sw::universal::operator== (double lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs>
constexpr bool sw::universal::operator!= (double lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs>
constexpr bool sw::universal::operator< (double lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs>
constexpr bool sw::universal::operator> (double lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs>
constexpr bool sw::universal::operator<= (double lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs>
constexpr bool sw::universal::operator>= (double lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator== (Integer lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator!= (Integer lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator< (Integer lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator> (Integer lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator<= (Integer lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr bool sw::universal::operator>= (Integer lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator+ (const efloat< nlimbs > &lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator- (const efloat< nlimbs > &lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator* (const efloat< nlimbs > &lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator/ (const efloat< nlimbs > &lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator+ (efloat< nlimbs > &&lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator- (efloat< nlimbs > &&lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator* (efloat< nlimbs > &&lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator/ (efloat< nlimbs > &&lhs, const efloat< nlimbs > &rhs) noexcept
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator+ (const efloat< nlimbs > &lhs, double rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr efloat< nlimbs > sw::universal::operator+ (const efloat< nlimbs > &lhs, Integer rhs)
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator- (const efloat< nlimbs > &lhs, double rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr efloat< nlimbs > sw::universal::operator- (const efloat< nlimbs > &lhs, Integer rhs)
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator* (const efloat< nlimbs > &lhs, double rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr efloat< nlimbs > sw::universal::operator* (const efloat< nlimbs > &lhs, Integer rhs)
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator/ (const efloat< nlimbs > &lhs, double rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr efloat< nlimbs > sw::universal::operator/ (const efloat< nlimbs > &lhs, Integer rhs)
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator+ (double lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr efloat< nlimbs > sw::universal::operator+ (Integer lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator- (double lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr efloat< nlimbs > sw::universal::operator- (Integer lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator* (double lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr efloat< nlimbs > sw::universal::operator* (Integer lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs>
constexpr efloat< nlimbs > sw::universal::operator/ (double lhs, const efloat< nlimbs > &rhs)
template<unsigned nlimbs, typename Integer, typename = std::enable_if_t<std::is_integral_v<Integer>>>
constexpr efloat< nlimbs > sw::universal::operator/ (Integer lhs, const efloat< nlimbs > &rhs)
void sw::universal::efloat_detail::append_exponent (std::string &str, std::int64_t e)
void sw::universal::efloat_detail::round_string (std::vector< char > &s, int precision, int *decimalPoint)
template<unsigned nlimbs>
void sw::universal::efloat_detail::to_digits (const efloat< nlimbs > &value, std::vector< char > &s, std::int64_t &exponent, int precision)

Variables

RoundingMode sw::universal::efloat_rounding_mode = RoundingMode::RoundToNearest
unsigned sw::universal::efloat_default_precision_bits = 0
constexpr unsigned sw::universal::efloat_parse_detail::guard_bits = 64u
constexpr std::int64_t sw::universal::efloat_parse_detail::exponent_limit = std::int64_t(4'000'000'000'000'000'000)

Macro Definition Documentation

◆ EFLOAT_ENABLE_LITERALS

#define EFLOAT_ENABLE_LITERALS   1

BEHAVIORAL COMPILATION SWITCHES.

These default here rather than in the efloat.hpp umbrella, so that a translation unit which includes core.hpp directly gets the same defaults (#1334, #1436). Defining either before any efloat header still wins.

◆ EFLOAT_INLINE_LIMBS

#define EFLOAT_INLINE_LIMBS   8

◆ EFLOAT_THROW_ARITHMETIC_EXCEPTION

#define EFLOAT_THROW_ARITHMETIC_EXCEPTION   0