Quadruple-precision floats

Note

The functionality described in this section is available only if mp++ was configured with the MPPP_WITH_QUADMATH option enabled (see the installation instructions).

New in version 0.5.

#include <mp++/real128.hpp>

The real128 class

class mppp::real128

Quadruple-precision floating-point class.

This class represents real values encoded in the quadruple-precision IEEE 754 floating-point format (which features up to 36 decimal digits of precision). The class is a thin wrapper around the __float128 type and the quadmath library, available on GCC, Clang and the Intel compiler on most modern platforms, on top of which it provides the following additions:

  • interoperability with other mp++ classes,
  • consistent behaviour with respect to the conventions followed elsewhere in mp++ (e.g., values are default-initialised to zero rather than to indefinite values, conversions must be explicit, etc.),
  • enhanced compile-time (constexpr) capabilities,
  • a generic C++ API.

Most of the functionality is exposed via plain functions, with the general convention that the functions are named after the corresponding quadmath functions minus the trailing q suffix. For instance, the quadmath code

__float128 a = 1;
auto b = ::sinq(a);

that computes the sine of 1 in quadruple precision, storing the result in b, becomes in mp++

real128 a{1};
auto b = sin(a);

where the sin() function is resolved via argument-dependent lookup.

Various overloaded operators are provided. The common arithmetic operators (+, -, * and /) always return real128 as a result, promoting at most one operand to real128 before actually performing the computation. Similarly, the relational operators, ==, !=, <, >, <= and >= will promote at most one argument to real128 before performing the comparison. Alternative comparison functions treating NaNs specially are provided for use in the C++ standard library (and wherever strict weak ordering relations are needed).

The real128 class is a literal type, and, whenever possible, operations involving real128 are marked as constexpr. Some functions which are not constexpr in the quadmath library have been reimplemented as constexpr functions via compiler builtins.

A tutorial showcasing various features of real128 is available.

__float128 m_value

The internal value.

This class member gives direct access to the __float128 instance stored inside a real128.

constexpr real128()

Default constructor.

The default constructor will set this to zero.

real128(const real128&) = default
real128(real128&&) = default

real128 is trivially copy and move constructible.

explicit constexpr real128(__float128 x)

Constructor from a __float128.

This constructor will initialise the internal __float128 value to x.

Parameters
x – the __float128 that will be assigned to the internal value.
template<real128_interoperable T>
explicit constexpr real128(const T &x)

Constructor from interoperable types.

This constructor will initialise the internal value to x. Depending on the value and type of x, this may not be exactly equal to x after initialisation (e.g., if x is a very large integer).

Parameters
x – the value that will be used for the initialisation.
Throws
std::overflow_error – in case of (unlikely) overflow errors during initialisation.
template<string_type T>
explicit real128(const T &s)

Constructor from string.

This constructor will initialise this from the string_type s. The accepted string formats are detailed in the quadmath library’s documentation (see the link below). Leading whitespaces are accepted (and ignored), but trailing whitespaces will raise an error.

Parameters

s – the string that will be used to initialise this.

Throws
  • std::invalid_argument – if s does not represent a valid quadruple-precision floating-point value.
  • unspecified – any exception thrown by memory errors in standard containers.
explicit real128(const char *begin, const char *end)

Constructor from range of characters.

This constructor will initialise this from the content of the input half-open range, which is interpreted as the string representation of a floating-point value.

Internally, the constructor will copy the content of the range to a local buffer, add a string terminator, and invoke the constructor from string.

Parameters
  • begin – the begin of the input range.
  • end – the end of the input range.
Throws

unspecified – any exception thrown by the constructor from string or by memory errors in standard containers.

real128 &operator=(const real128&) = default
real128 &operator=(real128&&) = default

real128 is trivially copy and move assignable.

constexpr real128 &operator=(const __float128 &x)

Note

This operator is constexpr only if at least C++14 is being used.

Assignment from a __float128.

Parameters
x – the __float128 that will be assigned to the internal value.
Returns
a reference to this.
template<real128_interoperable T>
constexpr real128 &operator=(const T &x)

Note

This operator is constexpr only if at least C++14 is being used.

Assignment from interoperable types.

Parameters
x – the assignment argument.
Returns
a reference to this.
Throws
unspecified – any exception thrown by the construction of a real128 from x.
template<string_type T>
real128 &operator=(const T &s)

Assignment from string.

The body of this operator is equivalent to:

return *this = real128{s};

That is, a temporary real128 is constructed from s and it is then move-assigned to this.

Parameters
s – the string that will be used for the assignment.
Returns
a reference to this.
Throws
unspecified – any exception thrown by the constructor from string.
explicit constexpr operator __float128() const

Conversion to __float128.

Returns
a copy of the __float128 value stored internally.
template<real128_interoperable T>
explicit constexpr operator T() const

Conversion operator to interoperable types.

This operator will convert this to a real128_interoperable type.

Conversion to C++ types is implemented via direct cast, and thus no checks are performed to ensure that the value of this can be represented by the target type.

Conversion to rational, if successful, is exact.

Conversion to integral types will produce the truncated counterpart of this.

Returns
this converted to T.
Throws
std::domain_error – if this represents a non-finite value and T is integer or rational.
template<real128_interoperable T>
constexpr bool get(T &rop) const

Note

This member function is constexpr only if at least C++14 is being used.

Conversion member function to interoperable types.

This member function, similarly to the conversion operator, will convert this to a real128_interoperable type, storing the result of the conversion into rop. Differently from the conversion operator, this function does not raise any exception: if the conversion is successful, the function will return true, otherwise the function will return false. If the conversion fails, rop will not be altered. The conversion can fail only if T is either integer or rational, and this represents a non-finite value.

Parameters
rop – the variable which will store the result of the conversion.
Returns
true if the conversion succeeds, false otherwise.
std::string to_string() const

Convert to string.

This member function will convert this to a decimal string representation in scientific format. The number of significant digits in the output (36) guarantees that a real128 constructed from the returned string will have a value identical to the value of this.

The implementation uses the quadmath_snprintf() function from the quadmath library.

Returns
a decimal string representation of this.
Throws
std::runtime_error – if the internal call to the quadmath_snprintf() function fails.
std::tuple<std::uint_least8_t, std::uint_least16_t, std::uint_least64_t, std::uint_least64_t> get_ieee() const

Get the IEEE representation of the value.

This member function will return a tuple containing the IEEE quadruple-precision floating-point representation of the value. The returned tuple elements are, in order:

  • the sign of the value (1 for a negative sign bit, 0 for a positive sign bit),
  • the exponent (a 15-bit unsigned value),
  • the high part of the significand (a 48-bit unsigned value),
  • the low part of the significand (a 64-bit unsigned value).
Returns
a tuple containing the IEEE quadruple-precision floating-point representation of the value stored in this.
bool signbit() const

Sign bit.

This member function will return the value of the sign bit of this. That is, if this is not a NaN the function will return true if this is negative or \(-0\), false otherwise. If this is NaN, the sign bit of the NaN value will be returned.

Returns
true if the sign bit of this is set, false otherwise.
constexpr int fpclassify() const

Note

This function is not constexpr if the Intel C++ compiler is being used.

Categorise the floating point value.

This member function will categorise the floating-point value of this into the 5 categories, represented as int values, defined by the standard:

  • FP_NAN for NaN,
  • FP_INFINITE for infinite,
  • FP_NORMAL for normal values,
  • FP_SUBNORMAL for subnormal values,
  • FP_ZERO for zero.
Returns
the category to which the value of this belongs.
constexpr bool isnan() const
constexpr bool isinf() const
constexpr bool finite() const

Note

These functions are not constexpr if the Intel C++ compiler is being used.

Detect NaN, infinity or finite value.

Returns
true is the value of this is, respectively, NaN, an infinity or finite, false otherwise.
constexpr real128 &abs()

Note

This function is constexpr only if at least C++14 is being used.

Note

This function is not constexpr if the Intel C++ compiler is being used.

In-place absolute value.

This member function will set this to its absolute value.

Returns
a reference to this.
real128 &sqrt()
real128 &cbrt()

In-place roots.

These member functions will set this to, respectively:

  • \(\sqrt{x}\),
  • \(\sqrt[3]{x}\),

where \(x\) is the current value of this.

Returns
a reference to this.
real128 &sin()
real128 &cos()
real128 &tan()

In-place trigonometric functions.

These member functions will set this to, respectively:

  • \(\sin{x}\),
  • \(\cos{x}\),
  • \(\tan{x}\),

where \(x\) is the current value of this.

Returns
a reference to this.
real128 &asin()
real128 &acos()
real128 &atan()

In-place inverse trigonometric functions.

These member functions will set this to, respectively:

  • \(\arcsin{x}\),
  • \(\arccos{x}\),
  • \(\arctan{x}\),

where \(x\) is the current value of this.

Returns
a reference to this.
real128 &sinh()
real128 &cosh()
real128 &tanh()

In-place hyperbolic functions.

These member functions will set this to, respectively:

  • \(\sinh{x}\),
  • \(\cosh{x}\),
  • \(\tanh{x}\),

where \(x\) is the current value of this.

Returns
a reference to this.
real128 &asinh()
real128 &acosh()
real128 &atanh()

In-place inverse hyperbolic functions.

These member functions will set this to, respectively:

  • \(\operatorname{arcsinh}{x}\),
  • \(\operatorname{arccosh}{x}\),
  • \(\operatorname{arctanh}{x}\),

where \(x\) is the current value of this.

Returns
a reference to this.
real128 &exp()
real128 &log()
real128 &log10()
real128 &log2()

In-place logarithms and exponentials.

These member functions will set this to, respectively:

  • \(e^x\),
  • \(\log{x}\),
  • \(\log_{10}{x}\),
  • \(\log_2{x}\),

where \(x\) is the current value of this.

Returns
a reference to this.
real128 &lgamma()

In-place logarithm of the gamma function.

This member function will set this to \(\log\Gamma\left( x \right)\), where \(x\) is the current value of this.

Returns
a reference to this.
real128 &erf()

In-place error function.

This member function will set this to \(\operatorname{erf}\left( x \right)\), where \(x\) is the current value of this.

Returns
a reference to this.

Types

type __float128

A quadruple-precision floating-point type available on GCC, Clang and the Intel compiler. This is the type wrapped by the real128 class.

Concepts

template<typename T>
concept mppp::real128_interoperable

This concept is satisfied by types that can interoperate with real128. Specifically, this concept is satisfied if either:

template<typename T, typename U>
concept mppp::real128_op_types

This concept is satisfied if the types T and U are suitable for use in the generic binary operators involving real128 and other types. Specifically, the concept will be true if either:

Functions

Conversion

template<mppp::real128_interoperable T>
constexpr bool mppp::get(T &rop, const mppp::real128 &x)

Note

This function is constexpr only if at least C++14 is being used.

Conversion function.

This function will convert the input real128 x to a real128_interoperable type, storing the result of the conversion into rop. If the conversion is successful, the function will return true, otherwise the function will return false. If the conversion fails, rop will not be altered. The conversion can fail only if T is either integer or rational, and x represents a non-finite value.

Parameters
  • rop – the variable which will store the result of the conversion.
  • x – the input value.
Returns

true if the conversion succeeds, false otherwise.

mppp::real128 mppp::frexp(const mppp::real128 &x, int *exp)

Decompose a real128 into a normalized fraction and an integral power of two.

If x is zero, this function will return zero and store zero in exp. Otherwise, this function will return a real128 \(r\) with an absolute value in the \(\left[0.5,1\right)\) range, and it will store an integer value \(n\) in exp such that \(r \times 2^n\) equals to \(x\). If x is a non-finite value, the return value will be x and an unspecified value will be stored in exp.

Parameters
  • x – the input real128.
  • exp – a pointer to the value that will store the exponent.
Returns

the binary significand of x.

Arithmetic

mppp::real128 mppp::fma(const mppp::real128 &x, const mppp::real128 &y, const mppp::real128 &z)

Fused multiply-add.

This function will return \(\left(x \times y\right) + z\) as if calculated to infinite precision and rounded once.

Parameters
  • x – the first factor.
  • y – the second factor.
  • z – the addend.
Returns

\(\left(x \times y\right) + z\).

constexpr mppp::real128 mppp::abs(const mppp::real128 &x)

Note

This function is not constexpr if the Intel C++ compiler is being used.

Absolute value.

Parameters
x – the real128 whose absolute value will be computed.
Returns
\(\left| x \right|\).
mppp::real128 mppp::scalbn(const mppp::real128 &x, int n)
mppp::real128 mppp::scalbln(const mppp::real128 &x, long n)

Multiply by power of 2.

Parameters
  • x – the input real128.
  • n – the power of 2 by which x will be multiplied.
Returns

\(x \times 2^n\).

Comparison

bool mppp::signbit(const mppp::real128 &x)

Sign bit.

Parameters
x – the input value.
Returns
the sign bit of x (as returned by mppp::real128::signbit()).
constexpr int mppp::fpclassify(const mppp::real128 &x)

Note

This function is not constexpr if the Intel C++ compiler is being used.

Categorise a real128.

Parameters
x – the value whose floating-point category will be returned.
Returns
the category of the value of x, as established by mppp::real128::fpclassify().
constexpr bool mppp::isnan(const mppp::real128 &x)
constexpr bool mppp::isinf(const mppp::real128 &x)
constexpr bool mppp::finite(const mppp::real128 &x)

Note

These functions are not constexpr if the Intel C++ compiler is being used.

Detect special values.

These functions will return true is x is, respectively:

  • NaN,
  • an infinity,
  • a finite value,

and false otherwise.

Parameters
x – the input value.
Returns
a boolean flag indicating if x is NaN, an infinity or a finite value.
constexpr bool mppp::real128_equal_to(const mppp::real128 &x, const mppp::real128 &y)

Note

This function is not constexpr if the Intel C++ compiler is being used.

Equality predicate with special NaN handling.

If both x and y are not NaN, this function is identical to the equality operator. Otherwise, this function will return true if both operands are NaN, false otherwise.

In other words, this function behaves like an equality operator which considers all NaN values equal to each other.

Parameters
  • x – the first operand.
  • y – the second operand.
Returns

true if \(x = y\) (including the case in which both operands are NaN), false otherwise.

constexpr bool mppp::real128_lt(const mppp::real128 &x, const mppp::real128 &y)

Note

This function is not constexpr if the Intel C++ compiler is being used.

Less-than predicate with special NaN handling.

If both x and y are not NaN, this function is identical to the less-than operator. If at least one operand is NaN, this function will return true if x is not NaN, false otherwise.

In other words, this function behaves like a less-than operator which considers NaN values greater than non-NaN values. This function can be used as a comparator in various facilities of the standard library (e.g., std::sort(), std::set, etc.).

Parameters
  • x – the first operand.
  • y – the second operand.
Returns

true if \(x < y\) (with NaN values considered greather than non-NaN values), false otherwise.

constexpr bool mppp::real128_gt(const mppp::real128 &x, const mppp::real128 &y)

Note

This function is not constexpr if the Intel C++ compiler is being used.

Greater-than predicate with special NaN handling.

If both x and y are not NaN, this function is identical to the greater-than operator. If at least one operand is NaN, this function will return true if y is not NaN, false otherwise.

In other words, this function behaves like a greater-than operator which considers NaN values greater than non-NaN values. This function can be used as a comparator in various facilities of the standard library (e.g., std::sort(), std::set, etc.).

Parameters
  • x – the first operand.
  • y – the second operand.
Returns

true if \(x > y\) (with NaN values considered greather than non-NaN values), false otherwise.

Roots

mppp::real128 mppp::sqrt(mppp::real128 x)
mppp::real128 mppp::cbrt(mppp::real128 x)

Root functions.

These functions will return, respectively:

  • \(\sqrt{x}\),
  • \(\sqrt[3]{x}\).
Parameters
x – the input argument.
Returns
the square or cubic root of x.
mppp::real128 mppp::hypot(const mppp::real128 &x, const mppp::real128 &y)

Euclidean distance.

This function will return \(\sqrt{x^2+y^2}\). The calculation is performed without undue overflow or underflow during the intermediate steps of the calculation.

Parameters
  • x – the first argument.
  • y – the second argument.
Returns

\(\sqrt{x^2+y^2}\).

Exponentiation

template<typename T, mppp::real128_op_types<T> U>
mppp::real128 mppp::pow(const T &x, const U &y)

This function will compute \(x^y\). Internally, the implementation uses the powq() function from the quadmath library, after the conversion of one of the operands to real128 (if necessary).

Parameters
  • x – the base.
  • y – the exponent.
Returns

\(x^y\).

Trigonometry

mppp::real128 mppp::sin(mppp::real128 x)
mppp::real128 mppp::cos(mppp::real128 x)
mppp::real128 mppp::tan(mppp::real128 x)
mppp::real128 mppp::asin(mppp::real128 x)
mppp::real128 mppp::acos(mppp::real128 x)
mppp::real128 mppp::atan(mppp::real128 x)

Trigonometric functions.

These functions will return, respectively:

  • \(\sin x\),
  • \(\cos x\),
  • \(\tan x\),
  • \(\arcsin x\),
  • \(\arccos x\),
  • \(\arctan x\).
Parameters
x – the input value.
Returns
a trigonometric function of x.

Hyperbolic functions

mppp::real128 mppp::sinh(mppp::real128 x)
mppp::real128 mppp::cosh(mppp::real128 x)
mppp::real128 mppp::tanh(mppp::real128 x)
mppp::real128 mppp::asinh(mppp::real128 x)
mppp::real128 mppp::acosh(mppp::real128 x)
mppp::real128 mppp::atanh(mppp::real128 x)

Hyperbolic functions.

These functions will return, respectively:

  • \(\sinh x\),
  • \(\cosh x\),
  • \(\tanh x\),
  • \(\operatorname{arcsinh} x\),
  • \(\operatorname{arccosh} x\),
  • \(\operatorname{arctanh} x\).
Parameters
x – the input value.
Returns
a hyperbolic function of x.

Logarithms and exponentials

mppp::real128 mppp::exp(mppp::real128 x)

Exponential function.

Parameters
x – the input value.
Returns
\(e^x\).
mppp::real128 mppp::log(mppp::real128 x)
mppp::real128 mppp::log10(mppp::real128 x)
mppp::real128 mppp::log2(mppp::real128 x)

Logarithms.

These functions will return, respectively:

  • \(\log x\),
  • \(\log_{10} x\),
  • \(\log_2 x\).
Parameters
x – the input value.
Returns
a logarithm of x.

Gamma functions

mppp::real128 mppp::lgamma(mppp::real128 x)

Natural logarithm of the gamma function.

Parameters
x – the input value.
Returns
\(\log\Gamma\left( x \right)\).

Other special functions

mppp::real128 mppp::erf(mppp::real128 x)

Error function.

Parameters
x – the input value.
Returns
\(\operatorname{erf}\left( x \right)\).

Floating-point manipulation

mppp::real128 mppp::nextafter(const mppp::real128 &from, const mppp::real128 &to)

New in version 0.14.

This function returns the next representable value of from in the direction of to.

If from equals to to, to is returned.

Parameters
  • from – the real128 whose next representable value will be returned.
  • to – the direction of the next representable value.
Returns

the next representable value of from in the direction of to.

Input/Output

std::ostream &mppp::operator<<(std::ostream &os, const mppp::real128 &x)

Output stream operator.

This operator will print to the stream os the real128 x. The current implementation ignores any formatting flag specified in os, and the print format will be the one described in mppp::real128::to_string().

Warning

In future versions of mp++, the behaviour of this operator will change to support the output stream’s formatting flags. For the time being, users are encouraged to use the quadmath_snprintf() function from the quadmath library if precise and forward-compatible control on the printing format is needed.

Parameters
  • os – the target stream.
  • x – the input real128.
Returns

a reference to os.

Throws

unspecified – any exception thrown by mppp::real128::to_string().

Other

std::size_t mppp::hash(const mppp::real128 &x)

New in version 0.12.

Hash function for real128.

All NaN values produce the same hash value. For non-NaN arguments, this function guarantees that x == y implies hash(x) == hash(y).

Parameters
x – the argument.
Returns
a hash value for x.

Mathematical operators

constexpr mppp::real128 mppp::operator+(mppp::real128 x)
constexpr mppp::real128 mppp::operator-(mppp::real128 x)

Identity and negation.

Parameters
x – the argument.
Returns
\(x\) and \(-x\) respectively.
constexpr mppp::real128 &mppp::operator++(mppp::real128 &x)
constexpr mppp::real128 &mppp::operator--(mppp::real128 &x)

Note

These operators are constexpr only if at least C++14 is being used.

Prefix increment and decrement.

Parameters
x – the argument.
Returns
a reference to x after it has been incremented/decremented by one.
constexpr mppp::real128 mppp::operator++(mppp::real128 &x, int)
constexpr mppp::real128 mppp::operator--(mppp::real128 &x, int)

Note

These operators are constexpr only if at least C++14 is being used.

Suffix increment and decrement.

Parameters
x – the argument.
Returns
a copy of x before the increment/decrement.
template<typename T, mppp::real128_op_types<T> U>
constexpr mppp::real128 mppp::operator+(const T &x, const U &y)
template<typename T, mppp::real128_op_types<T> U>
constexpr mppp::real128 mppp::operator-(const T &x, const U &y)
template<typename T, mppp::real128_op_types<T> U>
constexpr mppp::real128 mppp::operator*(const T &x, const U &y)
template<typename T, mppp::real128_op_types<T> U>
constexpr mppp::real128 mppp::operator/(const T &x, const U &y)

Binary arithmetic operators.

These operators will return, respectively:

  • \(x+y\),
  • \(x-y\),
  • \(x \times y\),
  • \(x / y\).
Parameters
  • x – the first operand.
  • y – the second operand.
Returns

the result of the binary operation.

Throws

unspecified – any exception thrown by the constructor of real128 from mp++ types.

template<typename T, mppp::real128_op_types<T> U>
constexpr T &mppp::operator+=(T &x, const U &y)
template<typename T, mppp::real128_op_types<T> U>
constexpr T &mppp::operator-=(T &x, const U &y)
template<typename T, mppp::real128_op_types<T> U>
constexpr T &mppp::operator*=(T &x, const U &y)
template<typename T, mppp::real128_op_types<T> U>
constexpr T &mppp::operator/=(T &x, const U &y)

Note

These operators are constexpr only if at least C++14 is being used.

In-place arithmetic operators.

These operators will set x to, respectively:

  • \(x+y\),
  • \(x-y\),
  • \(x \times y\),
  • \(x / y\).
Parameters
  • x – the first operand.
  • y – the second operand.
Returns

a reference to x.

Throws

unspecified – any exception thrown by the corresponding binary operator, or by the conversion of real128 to mp++ types.

template<typename T, typename U>
constexpr bool mppp::operator==(const T &x, const U &y)
template<typename T, typename U>
constexpr bool mppp::operator!=(const T &x, const U &y)
template<typename T, typename U>
constexpr bool mppp::operator<(const T &x, const U &y)
template<typename T, typename U>
constexpr bool mppp::operator>(const T &x, const U &y)
template<typename T, typename U>
constexpr bool mppp::operator<=(const T &x, const U &y)
template<typename T, typename U>
constexpr bool mppp::operator>=(const T &x, const U &y)

Comparison operators.

These operators will return true if, respectively:

  • \(x=y\),
  • \(x \neq y\),
  • \(x < y\),
  • \(x > y\),
  • \(x \leq y\),
  • \(x \geq y\),

false otherwise.

Note

These operators will handle NaN in the same way as the builtin floating-point types. For alternative comparison functions that treat NaN specially, please see the comparison functions section.

Parameters
  • x – the first operand.
  • y – the second operand.
Returns

the result of the comparison.

Throws

unspecified – any exception thrown by the constructor of real128 from mp++ types.

Constants

A few mathematical constants are provided. The constants are available as inline variables (e.g., mppp::pi_128, requires C++17 or later) and as constexpr functions (e.g., mppp::real128_pi(), always available). Inline variables and constexpr functions provide exactly the same functionality, but inline variables are more convenient if C++17 is an option.

Note

Some of these constants are also available as macros from the quadmath library.

constexpr unsigned mppp::real128_sig_digits()
constexpr unsigned mppp::sig_digits_128

The number of binary digits in the significand of a real128 (113).

constexpr unsigned mppp::real128_max()
constexpr unsigned mppp::max_128

The maximum positive finite value representable by real128.

constexpr unsigned mppp::real128_min()
constexpr unsigned mppp::min_128

The minimum positive value representable by real128 with full precision.

constexpr unsigned mppp::real128_epsilon()
constexpr unsigned mppp::epsilon_128

The difference between 1 and the next larger number representable by real128 (\(2^{-112}\)).

constexpr unsigned mppp::real128_denorm_min()
constexpr unsigned mppp::denorm_min_128

The smallest positive denormalized number representable by real128.

constexpr unsigned mppp::real128_inf()
constexpr unsigned mppp::inf_128
constexpr unsigned mppp::real128_nan()
constexpr unsigned mppp::nan_128

Positive infinity and NaN.

constexpr unsigned mppp::real128_pi()
constexpr unsigned mppp::pi_128

Quadruple-precision \(\pi\) constant.

constexpr unsigned mppp::real128_e()
constexpr unsigned mppp::e_128

Quadruple-precision \(\text{e}\) constant (Euler’s number).

constexpr unsigned mppp::real128_sqrt2()
constexpr unsigned mppp::sqrt2_128

Quadruple-precision \(\sqrt{2}\) constant.

Standard library specialisations

template<>
class std::numeric_limits<mppp::real128>

This specialisation exposes the compile-time properties of real128 as specified by the C++ standard.

static constexpr bool is_specialized = true
static constexpr int digits = 113
static constexpr int digits10 = 33
static constexpr int max_digits10 = 36
static constexpr bool is_signed = true
static constexpr bool is_integer = false
static constexpr bool is_exact = false
static constexpr int radix = 2
static constexpr int min_exponent = -16381
static constexpr int min_exponent10 = -4931
static constexpr int max_exponent = 16384
static constexpr int max_exponent10 = 4931
static constexpr bool has_infinity = true
static constexpr bool has_quiet_NaN = true
static constexpr bool has_signaling_NaN = false
static constexpr std::float_denorm_style has_denorm = std::denorm_present
static constexpr bool has_denorm_loss = true
static constexpr bool is_iec559 = true
static constexpr bool is_bounded = false
static constexpr bool is_modulo = false
static constexpr bool traps = false
static constexpr bool tinyness_before = false
static constexpr std::float_round_style round_style = std::round_to_nearest
static constexpr mppp::real128 min()
Returns
the output of mppp::real128_min().
static constexpr mppp::real128 max()
Returns
the output of mppp::real128_max().
static constexpr mppp::real128 lowest()
Returns
the negative of the output of mppp::real128_max().
static constexpr mppp::real128 epsilon()
Returns
the output of mppp::real128_epsilon().
static constexpr mppp::real128 round_error()
Returns
0.5.
static constexpr mppp::real128 infinity()
Returns
the output of mppp::real128_inf().
static constexpr mppp::real128 quiet_NaN()
Returns
the output of mppp::real128_nan().
static constexpr mppp::real128 signaling_NaN()
Returns
0.
static constexpr mppp::real128 denorm_min()
Returns
the output of mppp::real128_denorm_min().

User-defined literal

New in version 0.19.

template<char... Chars>
mppp::real128 mppp::literals::operator""_rq()

User-defined quadruple-precision literal.

This numeric literal operator template can be used to construct real128 instances. Floating-point literals in decimal and hexadecimal format are supported.

Throws
std::invalid_argument – if the input sequence of characters is not a valid floating-point literal (as defined by the C++ standard).