sparrow 1.4.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
Loading...
Searching...
No Matches
half_float::half Class Reference

Half-precision floating-point type. More...

#include <float16_t.hpp>

Public Member Functions

detail::uint16 get_data () const
 
Construction and assignment
constexpr half () noexcept
 Default constructor.
 
template<detail::arithmetic T>
 half (T rhs)
 Conversion constructor.
 
 operator float () const
 Conversion to single-precision.
 
halfoperator= (const float &rhs)
 Assignment operator.
 
template<detail::arithmetic T>
halfoperator= (const T &rhs)
 
Arithmetic updates
halfoperator+= (half rhs)
 Arithmetic assignment.
 
halfoperator-= (half rhs)
 Arithmetic assignment.
 
halfoperator*= (half rhs)
 Arithmetic assignment.
 
halfoperator/= (half rhs)
 Arithmetic assignment.
 
Increment and decrement
halfoperator++ ()
 Prefix increment.
 
halfoperator-- ()
 Prefix decrement.
 
half operator++ (int)
 Postfix increment.
 
half operator-- (int)
 Postfix decrement.
 

Friends

template<class, class, std::float_round_style>
struct detail::half_caster
 
class std::numeric_limits< half >
 
struct std::hash< half >
 
constexpr_NOERR bool operator== (half x, half y)
 Comparison for equality.
 
template<detail::arithmetic T>
constexpr_NOERR bool operator== (half x, T y)
 
constexpr_NOERR std::partial_ordering operator<=> (half x, half y)
 
template<detail::arithmetic T>
constexpr_NOERR std::partial_ordering operator<=> (half x, T y)
 
constexpr half operator+ (half arg)
 Identity.
 
constexpr half operator- (half arg)
 Negation.
 
half operator+ (half x, half y)
 Addition.
 
template<class T>
half operator+ (half x, T y)
 
template<class T>
half operator+ (T x, half y)
 
half operator- (half x, half y)
 Subtraction.
 
template<class T>
half operator- (half x, T y)
 
template<class T>
half operator- (T x, half y)
 
half operator* (half x, half y)
 Multiplication.
 
template<class T>
half operator* (half x, T y)
 
template<class T>
half operator* (T x, half y)
 
half operator/ (half x, half y)
 Division.
 
template<class T>
half operator/ (half x, T y)
 
template<class T>
half operator/ (T x, half y)
 
template<class charT, class traits>
std::basic_ostream< charT, traits > & operator<< (std::basic_ostream< charT, traits > &out, half arg)
 Output operator.
 
template<class charT, class traits>
std::basic_istream< charT, traits > & operator>> (std::basic_istream< charT, traits > &in, half &arg)
 Input operator.
 
constexpr half fabs (half arg)
 Absolute value.
 
half fmod (half x, half y)
 Remainder of division.
 
half remainder (half x, half y)
 Remainder of division.
 
half remquo (half x, half y, int *quo)
 Remainder of division.
 
half fma (half x, half y, half z)
 Fused multiply add.
 
constexpr_NOERR half fmax (half x, half y)
 Maximum of half expressions.
 
constexpr_NOERR half fmin (half x, half y)
 Minimum of half expressions.
 
half fdim (half x, half y)
 Positive difference.
 
half nanh (const char *arg)
 Get NaN value.
 
half exp (half arg)
 Exponential function.
 
half exp2 (half arg)
 Binary exponential.
 
half expm1 (half arg)
 Exponential minus one.
 
half log (half arg)
 Natural logarithm.
 
half log10 (half arg)
 Common logarithm.
 
half log2 (half arg)
 Binary logarithm.
 
half log1p (half arg)
 Natural logarithm plus one.
 
half sqrt (half arg)
 Square root.
 
half cbrt (half arg)
 Cubic root.
 
half hypot (half x, half y)
 Hypotenuse function.
 
half hypot (half x, half y, half z)
 Hypotenuse function.
 
half pow (half x, half y)
 Power function.
 
void sincos (half arg, half *sin, half *cos)
 Compute sine and cosine simultaneously.
 
half sin (half arg)
 Sine function.
 
half cos (half arg)
 Cosine function.
 
half tan (half arg)
 Tangent function.
 
half asin (half arg)
 Arc sine.
 
half acos (half arg)
 Arc cosine function.
 
half atan (half arg)
 Arc tangent function.
 
half atan2 (half y, half x)
 Arc tangent function.
 
half sinh (half arg)
 Hyperbolic sine.
 
half cosh (half arg)
 Hyperbolic cosine.
 
half tanh (half arg)
 Hyperbolic tangent.
 
half asinh (half arg)
 Hyperbolic area sine.
 
half acosh (half arg)
 Hyperbolic area cosine.
 
half atanh (half arg)
 Hyperbolic area tangent.
 
half erf (half arg)
 Error function.
 
half erfc (half arg)
 Complementary error function.
 
half lgamma (half arg)
 Natural logarithm of gamma function.
 
half tgamma (half arg)
 Gamma function.
 
half ceil (half arg)
 Nearest integer not less than half value.
 
half floor (half arg)
 Nearest integer not greater than half value.
 
half trunc (half arg)
 Nearest integer not greater in magnitude than half value.
 
half round (half arg)
 Nearest integer.
 
long lround (half arg)
 Nearest integer.
 
half rint (half arg)
 Nearest integer using half's internal rounding mode.
 
long lrint (half arg)
 Nearest integer using half's internal rounding mode.
 
half nearbyint (half arg)
 Nearest integer using half's internal rounding mode.
 
long long llround (half arg)
 Nearest integer.
 
long long llrint (half arg)
 Nearest integer using half's internal rounding mode.
 
half frexp (half arg, int *exp)
 Decompress floating-point number.
 
half scalbln (half arg, long exp)
 Multiply by power of two.
 
half modf (half arg, half *iptr)
 Extract integer and fractional parts.
 
int ilogb (half arg)
 Extract exponent.
 
half logb (half arg)
 Extract exponent.
 
half nextafter (half from, half to)
 Next representable value.
 
half nexttoward (half from, long double to)
 Next representable value.
 
constexpr half copysign (half x, half y)
 Take sign.
 
constexpr int fpclassify (half arg)
 Classify floating-point value.
 
constexpr bool isfinite (half arg)
 Check if finite number.
 
constexpr bool isinf (half arg)
 Check for infinity.
 
constexpr bool isnan (half arg)
 Check for NaN.
 
constexpr bool isnormal (half arg)
 Check if normal number.
 
constexpr bool signbit (half arg)
 Check sign.
 
constexpr bool isgreater (half x, half y)
 Quiet comparison for greater than.
 
constexpr bool isgreaterequal (half x, half y)
 Quiet comparison for greater equal.
 
constexpr bool isless (half x, half y)
 Quiet comparison for less than.
 
constexpr bool islessequal (half x, half y)
 Quiet comparison for less equal.
 
constexpr bool islessgreater (half x, half y)
 Quiet comarison for less or greater.
 
half literal::operator""_h (long double)
 

Detailed Description

Half-precision floating-point type.

This class implements an IEEE-conformant half-precision floating-point type with the usual arithmetic operators and conversions. It is implicitly convertible to single-precision floating-point, which makes artihmetic expressions and functions with mixed-type operands to be of the most precise operand type.

According to the C++98/03 definition, the half type is not a POD type. But according to C++11's less strict and extended definitions it is both a standard layout type and a trivially copyable type (even if not a POD type), which means it can be standard-conformantly copied using raw binary copies. But in this context some more words about the actual size of the type. Although the half is representing an IEEE 16-bit type, it does not neccessarily have to be of exactly 16-bits size. But on any reasonable implementation the actual binary representation of this type will most probably not ivolve any additional "magic" or padding beyond the simple binary representation of the underlying 16-bit IEEE number, even if not strictly guaranteed by the standard. But even then it only has an actual size of 16 bits if your C++ implementation supports an unsigned integer type of exactly 16 bits width. But this should be the case on nearly any reasonable platform.

So if your C++ implementation is not totally exotic or imposes special alignment requirements, it is a reasonable assumption that the data of a half is just comprised of the 2 bytes of the underlying IEEE representation.

Definition at line 1679 of file float16_t.hpp.

Constructor & Destructor Documentation

◆ half() [1/2]

half_float::half::half ( )
inlineconstexprnoexcept

Default constructor.

This initializes the half to 0. Although this does not match the builtin types' default-initialization semantics and may be less efficient than no initialization, it is needed to provide proper value-initialization semantics.

Definition at line 1687 of file float16_t.hpp.

◆ half() [2/2]

template<detail::arithmetic T>
half_float::half::half ( T rhs)
inline

Conversion constructor.

Parameters
rhsfloat to convert
Exceptions
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding Conversion constructor.
Parameters
rhsfloat to convert
Exceptions
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 1698 of file float16_t.hpp.

Member Function Documentation

◆ get_data()

detail::uint16 half_float::half::get_data ( ) const
inline

Definition at line 1795 of file float16_t.hpp.

◆ operator float()

half_float::half::operator float ( ) const
inline

Conversion to single-precision.

Returns
single precision value representing expression value

Definition at line 1702 of file float16_t.hpp.

Here is the call graph for this function:

◆ operator*=()

half & half_float::half::operator*= ( half rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to multiply with
Returns
reference to this half
Exceptions
FE_...according to operator*(half,half)

Definition at line 1736 of file float16_t.hpp.

Here is the call graph for this function:

◆ operator++() [1/2]

half & half_float::half::operator++ ( )
inline

Prefix increment.

Returns
incremented half value
Exceptions
FE_...according to operator+(half,half)

Definition at line 1778 of file float16_t.hpp.

Here is the call graph for this function:

◆ operator++() [2/2]

half half_float::half::operator++ ( int )
inline

Postfix increment.

Returns
non-incremented half value
Exceptions
FE_...according to operator+(half,half)

Definition at line 1788 of file float16_t.hpp.

Here is the call graph for this function:

◆ operator+=()

half & half_float::half::operator+= ( half rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to add
Returns
reference to this half
Exceptions
FE_...according to operator+(half,half)

Definition at line 1722 of file float16_t.hpp.

Here is the call graph for this function:

◆ operator--() [1/2]

half & half_float::half::operator-- ( )
inline

Prefix decrement.

Returns
decremented half value
Exceptions
FE_...according to operator-(half,half)

Definition at line 1783 of file float16_t.hpp.

Here is the call graph for this function:

◆ operator--() [2/2]

half half_float::half::operator-- ( int )
inline

Postfix decrement.

Returns
non-decremented half value
Exceptions
FE_...according to operator-(half,half)

Definition at line 1793 of file float16_t.hpp.

Here is the call graph for this function:

◆ operator-=()

half & half_float::half::operator-= ( half rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to subtract
Returns
reference to this half
Exceptions
FE_...according to operator-(half,half)

Definition at line 1729 of file float16_t.hpp.

Here is the call graph for this function:

◆ operator/=()

half & half_float::half::operator/= ( half rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to divide by
Returns
reference to this half
Exceptions
FE_...according to operator/(half,half)

Definition at line 1743 of file float16_t.hpp.

Here is the call graph for this function:

◆ operator=() [1/2]

half & half_float::half::operator= ( const float & rhs)
inline

Assignment operator.

Parameters
rhssingle-precision value to copy from
Returns
reference to this half
Exceptions
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 1708 of file float16_t.hpp.

Here is the call graph for this function:

◆ operator=() [2/2]

template<detail::arithmetic T>
half & half_float::half::operator= ( const T & rhs)
inline

Definition at line 1711 of file float16_t.hpp.

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ acos

half acos ( half arg)
friend

Arc cosine function.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::acos.

Parameters
argfunction argument
Returns
arc cosine value of arg
Exceptions
FE_INVALIDfor signaling NaN or if abs(arg) > 1
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3181 of file float16_t.hpp.

◆ acosh

half acosh ( half arg)
friend

Hyperbolic area cosine.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::acosh.

Parameters
argfunction argument
Returns
area cosine value of arg
Exceptions
FE_INVALIDfor signaling NaN or arguments <1
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3397 of file float16_t.hpp.

◆ asin

half asin ( half arg)
friend

Arc sine.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::asin.

Parameters
argfunction argument
Returns
arc sine value of arg
Exceptions
FE_INVALIDfor signaling NaN or if abs(arg) > 1
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3153 of file float16_t.hpp.

◆ asinh

half asinh ( half arg)
friend

Hyperbolic area sine.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::asinh.

Parameters
argfunction argument
Returns
area sine value of arg
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3370 of file float16_t.hpp.

◆ atan

half atan ( half arg)
friend

Arc tangent function.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::atan.

Parameters
argfunction argument
Returns
arc tangent value of arg
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3205 of file float16_t.hpp.

◆ atan2

half atan2 ( half y,
half x )
friend

Arc tangent function.

This function may be 1 ULP off the correctly rounded exact result in ~0.005% of inputs for std::round_to_nearest, in ~0.1% of inputs for std::round_toward_zero and in ~0.02% of inputs for any other rounding mode.

See also: Documentation for std::atan2.

Parameters
ynumerator
xdenominator
Returns
arc tangent value
Exceptions
FE_INVALIDif x or y is signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3234 of file float16_t.hpp.

◆ atanh

half atanh ( half arg)
friend

Hyperbolic area tangent.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::atanh.

Parameters
argfunction argument
Returns
area tangent value of arg
Exceptions
FE_INVALIDfor signaling NaN or if abs(arg) > 1
FE_DIVBYZEROfor +/-1
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3421 of file float16_t.hpp.

◆ cbrt

half cbrt ( half arg)
friend

Cubic root.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::cbrt.

Parameters
argfunction argument
Returns
cubic root of arg
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2795 of file float16_t.hpp.

◆ ceil

half ceil ( half arg)
friend

Nearest integer not less than half value.

See also: Documentation for std::ceil.

Parameters
arghalf to round
Returns
nearest integer not less than arg
Exceptions
FE_INVALIDfor signaling NaN
FE_INEXACTif value had to be rounded

Definition at line 3554 of file float16_t.hpp.

◆ copysign

half copysign ( half x,
half y )
friend

Take sign.

See also: Documentation for std::copysign.

Parameters
xvalue to change sign for
yvalue to take sign from
Returns
value equal to x in magnitude and to y in sign

Definition at line 3818 of file float16_t.hpp.

◆ cos

half cos ( half arg)
friend

Cosine function.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::cos.

Parameters
argfunction argument
Returns
cosine value of arg
Exceptions
FE_INVALIDfor signaling NaN or infinity
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3090 of file float16_t.hpp.

◆ cosh

half cosh ( half arg)
friend

Hyperbolic cosine.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::cosh.

Parameters
argfunction argument
Returns
hyperbolic cosine value of arg
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3313 of file float16_t.hpp.

◆ detail::half_caster

template<class, class, std::float_round_style>
friend struct detail::half_caster
friend

Definition at line 1896 of file float16_t.hpp.

◆ erf

half erf ( half arg)
friend

Error function.

This function may be 1 ULP off the correctly rounded exact result for any rounding mode in <0.5% of inputs.

See also: Documentation for std::erf.

Parameters
argfunction argument
Returns
error function value of arg
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3453 of file float16_t.hpp.

◆ erfc

half erfc ( half arg)
friend

Complementary error function.

This function may be 1 ULP off the correctly rounded exact result for any rounding mode in <0.5% of inputs.

See also: Documentation for std::erfc.

Parameters
argfunction argument
Returns
1 minus error function value of arg
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3474 of file float16_t.hpp.

◆ exp

half exp ( half arg)
friend

Exponential function.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::exp.

Parameters
argfunction argument
Returns
e raised to arg
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2517 of file float16_t.hpp.

◆ exp2

half exp2 ( half arg)
friend

Binary exponential.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::exp2.

Parameters
argfunction argument
Returns
2 raised to arg
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2549 of file float16_t.hpp.

◆ expm1

half expm1 ( half arg)
friend

Exponential minus one.

This function may be 1 ULP off the correctly rounded exact result in <0.05% of inputs for std::round_to_nearest and in <1% of inputs for any other rounding mode.

See also: Documentation for std::expm1.

Parameters
argfunction argument
Returns
e raised to arg and subtracted by 1
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2583 of file float16_t.hpp.

◆ fabs

half fabs ( half arg)
friend

Absolute value.

See also: Documentation for std::fabs.

Parameters
argoperand
Returns
absolute value of arg

Definition at line 2323 of file float16_t.hpp.

◆ fdim

half fdim ( half x,
half y )
friend

Positive difference.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::fdim.

Parameters
xfirst operand
ysecond operand
Returns
x - y or 0 if difference negative
Exceptions
FE_...according to operator-(half,half)

Definition at line 2487 of file float16_t.hpp.

◆ floor

half floor ( half arg)
friend

Nearest integer not greater than half value.

See also: Documentation for std::floor.

Parameters
arghalf to round
Returns
nearest integer not greater than arg
Exceptions
FE_INVALIDfor signaling NaN
FE_INEXACTif value had to be rounded

Definition at line 3562 of file float16_t.hpp.

◆ fma

half fma ( half x,
half y,
half z )
friend

Fused multiply add.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::fma.

Parameters
xfirst operand
ysecond operand
zthird operand
Returns
( x * y ) + z rounded as one operation.
Exceptions
FE_INVALIDaccording to operator*() and operator+() unless any argument is a quiet NaN and no argument is a signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding the final addition

Definition at line 2400 of file float16_t.hpp.

◆ fmax

constexpr_NOERR half fmax ( half x,
half y )
friend

Maximum of half expressions.

See also: Documentation for std::fmax.

Parameters
xfirst operand
ysecond operand
Returns
maximum of operands, ignoring quiet NaNs
Exceptions
FE_INVALIDif x or y is signaling NaN

Definition at line 2463 of file float16_t.hpp.

◆ fmin

constexpr_NOERR half fmin ( half x,
half y )
friend

Minimum of half expressions.

See also: Documentation for std::fmin.

Parameters
xfirst operand
ysecond operand
Returns
minimum of operands, ignoring quiet NaNs
Exceptions
FE_INVALIDif x or y is signaling NaN

Definition at line 2474 of file float16_t.hpp.

◆ fmod

half fmod ( half x,
half y )
friend

Remainder of division.

See also: Documentation for std::fmod.

Parameters
xfirst operand
ysecond operand
Returns
remainder of floating-point division.
Exceptions
FE_INVALIDif x is infinite or y is 0 or if x or y is signaling NaN

Definition at line 2337 of file float16_t.hpp.

◆ fpclassify

int fpclassify ( half arg)
friend

Classify floating-point value.

See also: Documentation for std::fpclassify.

Parameters
argnumber to classify
Return values
FP_ZEROfor positive and negative zero
FP_SUBNORMALfor subnormal numbers
FP_INFINITYfor positive and negative infinity
FP_NANfor NaNs
FP_NORMALfor all other (normal) values

Definition at line 3833 of file float16_t.hpp.

◆ frexp

half frexp ( half arg,
int * exp )
friend

Decompress floating-point number.

See also: Documentation for std::frexp.

Parameters
argnumber to decompress
expaddress to store exponent at
Returns
significant in range [0.5, 1)
Exceptions
FE_INVALIDfor signaling NaN

Definition at line 3635 of file float16_t.hpp.

◆ hypot [1/2]

half hypot ( half x,
half y )
friend

Hypotenuse function.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::hypot.

Parameters
xfirst argument
ysecond argument
Returns
square root of sum of squares without internal over- or underflows
Exceptions
FE_INVALIDif x or y is signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding of the final square root

Definition at line 2840 of file float16_t.hpp.

◆ hypot [2/2]

half hypot ( half x,
half y,
half z )
friend

Hypotenuse function.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::hypot.

Parameters
xfirst argument
ysecond argument
zthird argument
Returns
square root of sum of squares without internal over- or underflows
Exceptions
FE_INVALIDif x, y or z is signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding of the final square root

Definition at line 2881 of file float16_t.hpp.

◆ ilogb

int ilogb ( half arg)
friend

Extract exponent.

See also: Documentation for std::ilogb.

Parameters
argnumber to query
Returns
floating-point exponent
Return values
FP_ILOGB0for zero
FP_ILOGBNANfor NaN
INT_MAXfor infinity
Exceptions
FE_INVALIDfor 0 or infinite values

Definition at line 3724 of file float16_t.hpp.

◆ isfinite

bool isfinite ( half arg)
friend

Check if finite number.

See also: Documentation for std::isfinite.

Parameters
argnumber to check
Return values
trueif neither infinity nor NaN
falseelse

Definition at line 3846 of file float16_t.hpp.

◆ isgreater

bool isgreater ( half x,
half y )
friend

Quiet comparison for greater than.

See also: Documentation for std::isgreater.

Parameters
xfirst operand
ysecond operand
Return values
trueif x greater than y
falseelse

Definition at line 3887 of file float16_t.hpp.

◆ isgreaterequal

bool isgreaterequal ( half x,
half y )
friend

Quiet comparison for greater equal.

See also: Documentation for std::isgreaterequal.

Parameters
xfirst operand
ysecond operand
Return values
trueif x greater equal y
falseelse

Definition at line 3897 of file float16_t.hpp.

◆ isinf

bool isinf ( half arg)
friend

Check for infinity.

See also: Documentation for std::isinf.

Parameters
argnumber to check
Return values
truefor positive or negative infinity
falseelse

Definition at line 3853 of file float16_t.hpp.

◆ isless

bool isless ( half x,
half y )
friend

Quiet comparison for less than.

See also: Documentation for std::isless.

Parameters
xfirst operand
ysecond operand
Return values
trueif x less than y
falseelse

Definition at line 3907 of file float16_t.hpp.

◆ islessequal

bool islessequal ( half x,
half y )
friend

Quiet comparison for less equal.

See also: Documentation for std::islessequal.

Parameters
xfirst operand
ysecond operand
Return values
trueif x less equal y
falseelse

Definition at line 3917 of file float16_t.hpp.

◆ islessgreater

bool islessgreater ( half x,
half y )
friend

Quiet comarison for less or greater.

See also: Documentation for std::islessgreater.

Parameters
xfirst operand
ysecond operand
Return values
trueif either less or greater
falseelse

Definition at line 3927 of file float16_t.hpp.

◆ isnan

bool isnan ( half arg)
friend

Check for NaN.

See also: Documentation for std::isnan.

Parameters
argnumber to check
Return values
truefor NaNs
falseelse

Definition at line 3860 of file float16_t.hpp.

◆ isnormal

bool isnormal ( half arg)
friend

Check if normal number.

See also: Documentation for std::isnormal.

Parameters
argnumber to check
Return values
trueif normal number
falseif either subnormal, zero, infinity or NaN

Definition at line 3867 of file float16_t.hpp.

◆ lgamma

half lgamma ( half arg)
friend

Natural logarithm of gamma function.

This function may be 1 ULP off the correctly rounded exact result for any rounding mode in ~0.025% of inputs.

See also: Documentation for std::lgamma.

Parameters
argfunction argument
Returns
natural logarith of gamma function for arg
Exceptions
FE_INVALIDfor signaling NaN
FE_DIVBYZEROfor 0 or negative integer arguments
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3498 of file float16_t.hpp.

◆ literal::operator""_h

half literal::operator""_h ( long double )
friend

◆ llrint

long long llrint ( half arg)
friend

Nearest integer using half's internal rounding mode.

See also: Documentation for std::llrint.

Parameters
arghalf expression to round
Returns
nearest integer using default rounding mode
Exceptions
FE_INVALIDif value is not representable as `long long`
FE_INEXACTif value had to be rounded

Definition at line 3622 of file float16_t.hpp.

◆ llround

long long llround ( half arg)
friend

Nearest integer.

See also: Documentation for std::llround.

Parameters
arghalf to round
Returns
nearest integer, rounded away from zero in half-way cases
Exceptions
FE_INVALIDif value is not representable as `long long`

Definition at line 3614 of file float16_t.hpp.

◆ log

half log ( half arg)
friend

Natural logarithm.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::log.

Parameters
argfunction argument
Returns
logarithm of arg to base e
Exceptions
FE_INVALIDfor signaling NaN or negative argument
FE_DIVBYZEROfor 0
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2630 of file float16_t.hpp.

◆ log10

half log10 ( half arg)
friend

Common logarithm.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::log10.

Parameters
argfunction argument
Returns
logarithm of arg to base 10
Exceptions
FE_INVALIDfor signaling NaN or negative argument
FE_DIVBYZEROfor 0
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2657 of file float16_t.hpp.

◆ log1p

half log1p ( half arg)
friend

Natural logarithm plus one.

This function may be 1 ULP off the correctly rounded exact result in <0.05% of inputs for std::round_to_nearest and in ~1% of inputs for any other rounding mode.

See also: Documentation for std::log1p.

Parameters
argfunction argument
Returns
logarithm of arg plus 1 to base e
Exceptions
FE_INVALIDfor signaling NaN or argument <-1
FE_DIVBYZEROfor -1
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2731 of file float16_t.hpp.

◆ log2

half log2 ( half arg)
friend

Binary logarithm.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::log2.

Parameters
argfunction argument
Returns
logarithm of arg to base 2
Exceptions
FE_INVALIDfor signaling NaN or negative argument
FE_DIVBYZEROfor 0
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2690 of file float16_t.hpp.

◆ logb

half logb ( half arg)
friend

Extract exponent.

See also: Documentation for std::logb.

Parameters
argnumber to query
Returns
floating-point exponent
Exceptions
FE_INVALIDfor signaling NaN
FE_DIVBYZEROfor 0

Definition at line 3747 of file float16_t.hpp.

◆ lrint

long lrint ( half arg)
friend

Nearest integer using half's internal rounding mode.

See also: Documentation for std::lrint.

Parameters
arghalf expression to round
Returns
nearest integer using default rounding mode
Exceptions
FE_INVALIDif value is not representable as `long`
FE_INEXACTif value had to be rounded

Definition at line 3601 of file float16_t.hpp.

◆ lround

long lround ( half arg)
friend

Nearest integer.

See also: Documentation for std::lround.

Parameters
arghalf to round
Returns
nearest integer, rounded away from zero in half-way cases
Exceptions
FE_INVALIDif value is not representable as `long`

Definition at line 3585 of file float16_t.hpp.

◆ modf

half modf ( half arg,
half * iptr )
friend

Extract integer and fractional parts.

See also: Documentation for std::modf.

Parameters
argnumber to decompress
iptraddress to store integer part at
Returns
fractional part
Exceptions
FE_INVALIDfor signaling NaN

Definition at line 3698 of file float16_t.hpp.

◆ nanh

half nanh ( const char * arg)
friend

Get NaN value.

See also: Documentation for std::nan.

Parameters
argstring code
Returns
quiet NaN

Definition at line 2497 of file float16_t.hpp.

◆ nearbyint

half nearbyint ( half arg)
friend

Nearest integer using half's internal rounding mode.

See also: Documentation for std::nearbyint.

Parameters
arghalf expression to round
Returns
nearest integer using default rounding mode
Exceptions
FE_INVALIDfor signaling NaN

Definition at line 3608 of file float16_t.hpp.

◆ nextafter

half nextafter ( half from,
half to )
friend

Next representable value.

See also: Documentation for std::nextafter.

Parameters
fromvalue to compute next representable value for
todirection towards which to compute next value
Returns
next representable value after from in direction towards to
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOWfor infinite result from finite argument
FE_UNDERFLOWfor subnormal result

Definition at line 3771 of file float16_t.hpp.

◆ nexttoward

half nexttoward ( half from,
long double to )
friend

Next representable value.

See also: Documentation for std::nexttoward.

Parameters
fromvalue to compute next representable value for
todirection towards which to compute next value
Returns
next representable value after from in direction towards to
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOWfor infinite result from finite argument
FE_UNDERFLOWfor subnormal result

Definition at line 3796 of file float16_t.hpp.

◆ operator* [1/3]

half operator* ( half x,
half y )
friend

Multiplication.

This operation is exact to rounding for all rounding modes.

Parameters
xleft operand
yright operand
Returns
product of half expressions
Exceptions
FE_INVALIDif multiplying 0 with infinity or if x or y is signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2208 of file float16_t.hpp.

◆ operator* [2/3]

template<class T>
half operator* ( half x,
T y )
friend

Definition at line 2232 of file float16_t.hpp.

◆ operator* [3/3]

template<class T>
half operator* ( T x,
half y )
friend

Definition at line 2234 of file float16_t.hpp.

◆ operator+ [1/4]

half operator+ ( half arg)
friend

Identity.

Parameters
argoperand
Returns
unchanged operand

Definition at line 2127 of file float16_t.hpp.

◆ operator+ [2/4]

half operator+ ( half x,
half y )
friend

Addition.

This operation is exact to rounding for all rounding modes.

Parameters
xleft operand
yright operand
Returns
sum of half expressions
Exceptions
FE_INVALIDif x and y are infinities with different signs or signaling NaNs
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2141 of file float16_t.hpp.

◆ operator+ [3/4]

template<class T>
half operator+ ( half x,
T y )
friend

Definition at line 2178 of file float16_t.hpp.

◆ operator+ [4/4]

template<class T>
half operator+ ( T x,
half y )
friend

Definition at line 2180 of file float16_t.hpp.

◆ operator- [1/4]

half operator- ( half arg)
friend

Negation.

Parameters
argoperand
Returns
negated operand

Definition at line 2132 of file float16_t.hpp.

◆ operator- [2/4]

half operator- ( half x,
half y )
friend

Subtraction.

This operation is exact to rounding for all rounding modes.

Parameters
xleft operand
yright operand
Returns
difference of half expressions
Exceptions
FE_INVALIDif x and y are infinities with equal signs or signaling NaNs
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2189 of file float16_t.hpp.

◆ operator- [3/4]

template<class T>
half operator- ( half x,
T y )
friend

Definition at line 2197 of file float16_t.hpp.

◆ operator- [4/4]

template<class T>
half operator- ( T x,
half y )
friend

Definition at line 2199 of file float16_t.hpp.

◆ operator/ [1/3]

half operator/ ( half x,
half y )
friend

Division.

This operation is exact to rounding for all rounding modes.

Parameters
xleft operand
yright operand
Returns
quotient of half expressions
Exceptions
FE_INVALIDif dividing 0s or infinities with each other or if x or y is signaling NaN
FE_DIVBYZEROif dividing finite value by 0
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2244 of file float16_t.hpp.

◆ operator/ [2/3]

template<class T>
half operator/ ( half x,
T y )
friend

Definition at line 2272 of file float16_t.hpp.

◆ operator/ [3/3]

template<class T>
half operator/ ( T x,
half y )
friend

Definition at line 2274 of file float16_t.hpp.

◆ operator<<

template<class charT, class traits>
std::basic_ostream< charT, traits > & operator<< ( std::basic_ostream< charT, traits > & out,
half arg )
friend

Output operator.

This uses the built-in functionality for streaming out floating-point numbers.

Parameters
outoutput stream to write into
arghalf expression to write
Returns
reference to output stream

Definition at line 2274 of file float16_t.hpp.

◆ operator<=> [1/2]

constexpr_NOERR std::partial_ordering operator<=> ( half x,
half y )
friend

Definition at line 2103 of file float16_t.hpp.

◆ operator<=> [2/2]

template<detail::arithmetic T>
constexpr_NOERR std::partial_ordering operator<=> ( half x,
T y )
friend

Definition at line 2114 of file float16_t.hpp.

◆ operator== [1/2]

constexpr_NOERR bool operator== ( half x,
half y )
friend

Comparison for equality.

Parameters
xfirst operand
ysecond operand
Return values
trueif operands equal
falseelse
Exceptions
FE_INVALIDif x or y is NaN

Definition at line 2097 of file float16_t.hpp.

◆ operator== [2/2]

template<detail::arithmetic T>
constexpr_NOERR bool operator== ( half x,
T y )
friend

Definition at line 2101 of file float16_t.hpp.

◆ operator>>

template<class charT, class traits>
std::basic_istream< charT, traits > & operator>> ( std::basic_istream< charT, traits > & in,
half & arg )
friend

Input operator.

This uses the built-in functionality for streaming in floating-point numbers, specifically double precision floating point numbers (unless overridden with HALF_ARITHMETIC_TYPE). So the input string is first rounded to double precision using the underlying platform's current floating-point rounding mode before being rounded to half-precision using the library's half-precision rounding mode.

Parameters
ininput stream to read from
arghalf to read into
Returns
reference to input stream
Exceptions
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2303 of file float16_t.hpp.

◆ pow

half pow ( half x,
half y )
friend

Power function.

This function may be 1 ULP off the correctly rounded exact result for any rounding mode in ~0.00025% of inputs.

See also: Documentation for std::pow.

Parameters
xbase
yexponent
Returns
x raised to y
Exceptions
FE_INVALIDif x or y is signaling NaN or if x is finite an negative and y is finite and not integral
FE_DIVBYZEROif x is 0 and y is negative
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2944 of file float16_t.hpp.

◆ remainder

half remainder ( half x,
half y )
friend

Remainder of division.

See also: Documentation for std::remainder.

Parameters
xfirst operand
ysecond operand
Returns
remainder of floating-point division.
Exceptions
FE_INVALIDif x is infinite or y is 0 or if x or y is signaling NaN

Definition at line 2357 of file float16_t.hpp.

◆ remquo

half remquo ( half x,
half y,
int * quo )
friend

Remainder of division.

See also: Documentation for std::remquo.

Parameters
xfirst operand
ysecond operand
quoaddress to store some bits of quotient at
Returns
remainder of floating-point division.
Exceptions
FE_INVALIDif x is infinite or y is 0 or if x or y is signaling NaN

Definition at line 2376 of file float16_t.hpp.

◆ rint

half rint ( half arg)
friend

Nearest integer using half's internal rounding mode.

See also: Documentation for std::rint.

Parameters
arghalf expression to round
Returns
nearest integer using default rounding mode
Exceptions
FE_INVALIDfor signaling NaN
FE_INEXACTif value had to be rounded

Definition at line 3593 of file float16_t.hpp.

◆ round

half round ( half arg)
friend

Nearest integer.

See also: Documentation for std::round.

Parameters
arghalf to round
Returns
nearest integer, rounded away from zero in half-way cases
Exceptions
FE_INVALIDfor signaling NaN
FE_INEXACTif value had to be rounded

Definition at line 3578 of file float16_t.hpp.

◆ scalbln

half scalbln ( half arg,
long exp )
friend

Multiply by power of two.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::scalbln.

Parameters
argnumber to modify
exppower of two to multiply with
Returns
arg multplied by 2 raised to exp
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3654 of file float16_t.hpp.

◆ signbit

bool signbit ( half arg)
friend

Check sign.

See also: Documentation for std::signbit.

Parameters
argnumber to check
Return values
truefor negative number
falsefor positive number

Definition at line 3874 of file float16_t.hpp.

◆ sin

half sin ( half arg)
friend

Sine function.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::sin.

Parameters
argfunction argument
Returns
sine value of arg
Exceptions
FE_INVALIDfor signaling NaN or infinity
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3059 of file float16_t.hpp.

◆ sincos

void sincos ( half arg,
half * sin,
half * cos )
friend

Compute sine and cosine simultaneously.

This returns the same results as sin() and cos() but is faster than calling each function individually.

This function is exact to rounding for all rounding modes.

Parameters
argfunction argument
sinvariable to take sine of arg
cosvariable to take cosine of arg
Exceptions
FE_INVALIDfor signaling NaN or infinity
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3003 of file float16_t.hpp.

◆ sinh

half sinh ( half arg)
friend

Hyperbolic sine.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::sinh.

Parameters
argfunction argument
Returns
hyperbolic sine value of arg
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3286 of file float16_t.hpp.

◆ sqrt

half sqrt ( half arg)
friend

Square root.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::sqrt.

Parameters
argfunction argument
Returns
square root of arg
Exceptions
FE_INVALIDfor signaling NaN and negative arguments
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 2774 of file float16_t.hpp.

◆ std::hash< half >

friend struct std::hash< half >
friend

Definition at line 1896 of file float16_t.hpp.

◆ std::numeric_limits< half >

friend class std::numeric_limits< half >
friend

Definition at line 1896 of file float16_t.hpp.

◆ tan

half tan ( half arg)
friend

Tangent function.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::tan.

Parameters
argfunction argument
Returns
tangent value of arg
Exceptions
FE_INVALIDfor signaling NaN or infinity
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3118 of file float16_t.hpp.

◆ tanh

half tanh ( half arg)
friend

Hyperbolic tangent.

This function is exact to rounding for all rounding modes.

See also: Documentation for std::tanh.

Parameters
argfunction argument
Returns
hyperbolic tangent value of arg
Exceptions
FE_INVALIDfor signaling NaN
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3339 of file float16_t.hpp.

◆ tgamma

half tgamma ( half arg)
friend

Gamma function.

This function may be 1 ULP off the correctly rounded exact result for any rounding mode in <0.25% of inputs.

See also: Documentation for std::tgamma.

Parameters
argfunction argument
Returns
gamma function value of arg
Exceptions
FE_INVALIDfor signaling NaN, negative infinity or negative integer arguments
FE_DIVBYZEROfor 0
FE_OVERFLOW,...UNDERFLOW,...INEXACTaccording to rounding

Definition at line 3522 of file float16_t.hpp.

◆ trunc

half trunc ( half arg)
friend

Nearest integer not greater in magnitude than half value.

See also: Documentation for std::trunc.

Parameters
arghalf to round
Returns
nearest integer not greater in magnitude than arg
Exceptions
FE_INVALIDfor signaling NaN
FE_INEXACTif value had to be rounded

Definition at line 3570 of file float16_t.hpp.


The documentation for this class was generated from the following file: