#include <half.hpp>
Public Member Functions | |
Construction and assignment | |
HALF_CONSTEXPR | half () HALF_NOEXCEPT |
half (float rhs) | |
operator float () const | |
half & | operator= (float rhs) |
Arithmetic updates | |
half & | operator+= (half rhs) |
half & | operator-= (half rhs) |
half & | operator*= (half rhs) |
half & | operator/= (half rhs) |
half & | operator+= (float rhs) |
half & | operator-= (float rhs) |
half & | operator*= (float rhs) |
half & | operator/= (float rhs) |
Increment and decrement | |
half & | operator++ () |
half & | operator-- () |
half | operator++ (int) |
half | operator-- (int) |
Private Member Functions | |
HALF_CONSTEXPR | half (detail::binary_t, unsigned int bits) HALF_NOEXCEPT |
Private Attributes | |
detail::uint16 | data_ |
Internal binary representation. More... | |
Static Private Attributes | |
static const std::float_round_style | round_style = (std::float_round_style)(HALF_ROUND_STYLE) |
Rounding mode to use. More... | |
Friends | |
template<typename , typename , std::float_round_style > | |
struct | detail::half_caster |
class | std::numeric_limits< half > |
HALF_CONSTEXPR_NOERR bool | operator== (half, half) |
HALF_CONSTEXPR_NOERR bool | operator!= (half, half) |
HALF_CONSTEXPR_NOERR bool | operator< (half, half) |
HALF_CONSTEXPR_NOERR bool | operator> (half, half) |
HALF_CONSTEXPR_NOERR bool | operator<= (half, half) |
HALF_CONSTEXPR_NOERR bool | operator>= (half, half) |
HALF_CONSTEXPR half | operator- (half) |
half | operator+ (half, half) |
half | operator- (half, half) |
half | operator* (half, half) |
half | operator/ (half, half) |
template<typename charT , typename traits > | |
std::basic_ostream< charT, traits > & | operator<< (std::basic_ostream< charT, traits > &, half) |
template<typename charT , typename traits > | |
std::basic_istream< charT, traits > & | operator>> (std::basic_istream< charT, traits > &, half &) |
HALF_CONSTEXPR half | fabs (half) |
half | fmod (half, half) |
half | remainder (half, half) |
half | remquo (half, half, int *) |
half | fma (half, half, half) |
HALF_CONSTEXPR_NOERR half | fmax (half, half) |
HALF_CONSTEXPR_NOERR half | fmin (half, half) |
half | fdim (half, half) |
half | nanh (const char *) |
half | exp (half) |
half | exp2 (half) |
half | expm1 (half) |
half | log (half) |
half | log10 (half) |
half | log2 (half) |
half | log1p (half) |
half | sqrt (half) |
half | rsqrt (half) |
half | cbrt (half) |
half | hypot (half, half) |
half | hypot (half, half, half) |
half | pow (half, half) |
void | sincos (half, half *, half *) |
half | sin (half) |
half | cos (half) |
half | tan (half) |
half | asin (half) |
half | acos (half) |
half | atan (half) |
half | atan2 (half, half) |
half | sinh (half) |
half | cosh (half) |
half | tanh (half) |
half | asinh (half) |
half | acosh (half) |
half | atanh (half) |
half | erf (half) |
half | erfc (half) |
half | lgamma (half) |
half | tgamma (half) |
half | ceil (half) |
half | floor (half) |
half | trunc (half) |
half | round (half) |
long | lround (half) |
half | rint (half) |
long | lrint (half) |
half | nearbyint (half) |
half | frexp (half, int *) |
half | scalbln (half, long) |
half | modf (half, half *) |
int | ilogb (half) |
half | logb (half) |
half | nextafter (half, half) |
half | nexttoward (half, long double) |
HALF_CONSTEXPR half | copysign (half, half) |
HALF_CONSTEXPR int | fpclassify (half) |
HALF_CONSTEXPR bool | isfinite (half) |
HALF_CONSTEXPR bool | isinf (half) |
HALF_CONSTEXPR bool | isnan (half) |
HALF_CONSTEXPR bool | isnormal (half) |
HALF_CONSTEXPR bool | signbit (half) |
HALF_CONSTEXPR bool | isgreater (half, half) |
HALF_CONSTEXPR bool | isgreaterequal (half, half) |
HALF_CONSTEXPR bool | isless (half, half) |
HALF_CONSTEXPR bool | islessequal (half, half) |
HALF_CONSTEXPR bool | islessgreater (half, half) |
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.
|
inline |
|
inlineexplicit |
|
inlineprivate |
|
inline |
|
inline |
Arithmetic assignment.
rhs | single-precision value to multiply with |
FE_... | according to operator=() |
Arithmetic assignment.
T | type of concrete half expression |
rhs | half expression to multiply with |
FE_... | according to operator*(half,half) |
|
inline |
|
inline |
Postfix increment.
FE_... | according to operator+(half,half) |
|
inline |
Arithmetic assignment.
rhs | single-precision value to add |
FE_... | according to operator=() |
Arithmetic assignment.
T | type of concrete half expression |
rhs | half expression to add |
FE_... | according to operator+(half,half) |
|
inline |
|
inline |
Postfix decrement.
FE_... | according to operator-(half,half) |
|
inline |
Arithmetic assignment.
rhs | single-precision value to subtract |
FE_... | according to operator=() |
Arithmetic assignment.
T | type of concrete half expression |
rhs | half expression to subtract |
FE_... | according to operator-(half,half) |
|
inline |
Arithmetic assignment.
rhs | single-precision value to divide by |
FE_... | according to operator=() |
Arithmetic assignment.
T | type of concrete half expression |
rhs | half expression to divide by |
FE_... | according to operator/(half,half) |
|
inline |
Arc cosine function. This function is exact to rounding for all rounding modes.
See also: Documentation for std::acos.
arg | function argument |
FE_INVALID | for signaling NaN or if abs(arg) > 1 |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Hyperbolic area cosine. This function is exact to rounding for all rounding modes.
See also: Documentation for std::acosh.
arg | function argument |
FE_INVALID | for signaling NaN or arguments <1 |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Arc sine. This function is exact to rounding for all rounding modes.
See also: Documentation for std::asin.
arg | function argument |
FE_INVALID | for signaling NaN or if abs(arg) > 1 |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Hyperbolic area sine. This function is exact to rounding for all rounding modes.
See also: Documentation for std::asinh.
arg | function argument |
FE_INVALID | for signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Arc tangent function. This function is exact to rounding for all rounding modes.
See also: Documentation for std::atan.
arg | function argument |
FE_INVALID | for signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
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.
y | numerator |
x | denominator |
FE_INVALID | if x or y is signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Hyperbolic area tangent. This function is exact to rounding for all rounding modes.
See also: Documentation for std::atanh.
arg | function argument |
FE_INVALID | for signaling NaN or if abs(arg) > 1 |
FE_DIVBYZERO | for +/-1 |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Take sign. See also: Documentation for std::copysign.
x | value to change sign for |
y | value to take sign from |
Cosine function. This function is exact to rounding for all rounding modes.
See also: Documentation for std::cos.
arg | function argument |
FE_INVALID | for signaling NaN or infinity |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Hyperbolic cosine. This function is exact to rounding for all rounding modes.
See also: Documentation for std::cosh.
arg | function argument |
FE_INVALID | for signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
|
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.
arg | function argument |
FE_INVALID | for signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
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.
arg | function argument |
FE_INVALID | for signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Exponential function. This function is exact to rounding for all rounding modes.
See also: Documentation for std::exp.
arg | function argument |
FE_INVALID | for signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Binary exponential. This function is exact to rounding for all rounding modes.
See also: Documentation for std::exp2.
arg | function argument |
FE_INVALID | for signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
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.
arg | function argument |
FE_INVALID | for signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Positive difference. This function is exact to rounding for all rounding modes.
See also: Documentation for std::fdim.
x | first operand |
y | second operand |
FE_... | according to operator-(half,half) |
Nearest integer not greater than half value. See also: Documentation for std::floor.
arg | half to round |
FE_INVALID | for signaling NaN |
FE_INEXACT | if value had to be rounded |
Fused multiply add. This function is exact to rounding for all rounding modes.
See also: Documentation for std::fma.
x | first operand |
y | second operand |
z | third operand |
FE_INVALID | according to operator*() and operator+() unless any argument is a quiet NaN and no argument is a signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding the final addition |
|
friend |
Classify floating-point value. See also: Documentation for std::fpclassify.
arg | number to classify |
FP_ZERO | for positive and negative zero |
FP_SUBNORMAL | for subnormal numbers |
FP_INFINITY | for positive and negative infinity |
FP_NAN | for NaNs |
FP_NORMAL | for all other (normal) values |
Decompress floating-point number. See also: Documentation for std::frexp.
arg | number to decompress |
exp | address to store exponent at |
FE_INVALID | for signaling NaN |
Hypotenuse function. This function is exact to rounding for all rounding modes.
See also: Documentation for std::hypot.
x | first argument |
y | second argument |
FE_INVALID | if x or y is signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding of the final square root |
Hypotenuse function. This function is exact to rounding for all rounding modes.
See also: Documentation for std::hypot.
x | first argument |
y | second argument |
z | third argument |
FE_INVALID | if x, y or z is signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding of the final square root |
|
friend |
Extract exponent. See also: Documentation for std::ilogb.
arg | number to query |
FP_ILOGB0 | for zero |
FP_ILOGBNAN | for NaN |
INT_MAX | for infinity |
FE_INVALID | for 0 or infinite values |
|
friend |
Check if finite number. See also: Documentation for std::isfinite.
arg | number to check |
true | if neither infinity nor NaN |
false | else |
Quiet comparison for greater than. See also: Documentation for std::isgreater.
x | first operand |
y | second operand |
true | if x greater than y |
false | else |
Quiet comparison for greater equal. See also: Documentation for std::isgreaterequal.
x | first operand |
y | second operand |
true | if x greater equal y |
false | else |
|
friend |
Check for infinity. See also: Documentation for std::isinf.
arg | number to check |
true | for positive or negative infinity |
false | else |
Quiet comparison for less than. See also: Documentation for std::isless.
x | first operand |
y | second operand |
true | if x less than y |
false | else |
Quiet comparison for less equal. See also: Documentation for std::islessequal.
x | first operand |
y | second operand |
true | if x less equal y |
false | else |
Quiet comarison for less or greater. See also: Documentation for std::islessgreater.
x | first operand |
y | second operand |
true | if either less or greater |
false | else |
|
friend |
Check for NaN. See also: Documentation for std::isnan.
arg | number to check |
true | for NaNs |
false | else |
|
friend |
Check if normal number. See also: Documentation for std::isnormal.
arg | number to check |
true | if normal number |
false | if either subnormal, zero, infinity or NaN |
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.
arg | function argument |
FE_INVALID | for signaling NaN |
FE_DIVBYZERO | for 0 or negative integer arguments |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Natural logarithm. This function is exact to rounding for all rounding modes.
See also: Documentation for std::log.
arg | function argument |
FE_INVALID | for signaling NaN or negative argument |
FE_DIVBYZERO | for 0 |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Common logarithm. This function is exact to rounding for all rounding modes.
See also: Documentation for std::log10.
arg | function argument |
FE_INVALID | for signaling NaN or negative argument |
FE_DIVBYZERO | for 0 |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
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.
arg | function argument |
FE_INVALID | for signaling NaN or argument <-1 |
FE_DIVBYZERO | for -1 |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Binary logarithm. This function is exact to rounding for all rounding modes.
See also: Documentation for std::log2.
arg | function argument |
FE_INVALID | for signaling NaN or negative argument |
FE_DIVBYZERO | for 0 |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
|
friend |
Nearest integer using half's internal rounding mode. See also: Documentation for std::lrint.
arg | half expression to round |
FE_INVALID | if value is not representable as long |
FE_INEXACT | if value had to be rounded |
|
friend |
Nearest integer. See also: Documentation for std::lround.
arg | half to round |
FE_INVALID | if value is not representable as long |
|
friend |
Nearest integer using half's internal rounding mode. See also: Documentation for std::nearbyint.
arg | half expression to round |
FE_INVALID | for signaling NaN |
Next representable value. See also: Documentation for std::nextafter.
from | value to compute next representable value for |
to | direction towards which to compute next value |
FE_INVALID | for signaling NaN |
FE_OVERFLOW | for infinite result from finite argument |
FE_UNDERFLOW | for subnormal result |
Next representable value. See also: Documentation for std::nexttoward.
from | value to compute next representable value for |
to | direction towards which to compute next value |
FE_INVALID | for signaling NaN |
FE_OVERFLOW | for infinite result from finite argument |
FE_UNDERFLOW | for subnormal result |
Multiplication. This operation is exact to rounding for all rounding modes.
x | left operand |
y | right operand |
FE_INVALID | if multiplying 0 with infinity or if x or y is signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Addition. This operation is exact to rounding for all rounding modes.
x | left operand |
y | right operand |
FE_INVALID | if x and y are infinities with different signs or signaling NaNs |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Subtraction. This operation is exact to rounding for all rounding modes.
x | left operand |
y | right operand |
FE_INVALID | if x and y are infinities with equal signs or signaling NaNs |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Division. This operation is exact to rounding for all rounding modes.
x | left operand |
y | right operand |
FE_INVALID | if dividing 0s or infinities with each other or if x or y is signaling NaN |
FE_DIVBYZERO | if dividing finite value by 0 |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
|
friend |
|
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.
in | input stream to read from |
arg | half to read into |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
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.
x | base |
y | exponent |
FE_INVALID | if x or y is signaling NaN or if x is finite an negative and y is finite and not integral |
FE_DIVBYZERO | if x is 0 and y is negative |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Remainder of division. See also: Documentation for std::remainder.
x | first operand |
y | second operand |
FE_INVALID | if x is infinite or y is 0 or if x or y is signaling NaN |
Remainder of division. See also: Documentation for std::remquo.
x | first operand |
y | second operand |
quo | address to store some bits of quotient at |
FE_INVALID | if x is infinite or y is 0 or if x or y is signaling NaN |
Nearest integer. See also: Documentation for std::round.
arg | half to round |
FE_INVALID | for signaling NaN |
FE_INEXACT | if value had to be rounded |
Inverse square root. This function is exact to rounding for all rounding modes and thus generally more accurate than directly computing 1 / sqrt(arg) in half-precision, in addition to also being faster.
arg | function argument |
FE_INVALID | for signaling NaN and negative arguments |
FE_INEXACT | according to rounding |
Multiply by power of two. This function is exact to rounding for all rounding modes.
See also: Documentation for std::scalbln.
arg | number to modify |
exp | power of two to multiply with |
FE_INVALID | for signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
|
friend |
Check sign. See also: Documentation for std::signbit.
arg | number to check |
true | for negative number |
false | for positive number |
Sine function. This function is exact to rounding for all rounding modes.
See also: Documentation for std::sin.
arg | function argument |
FE_INVALID | for signaling NaN or infinity |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
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.
arg | function argument |
sin | variable to take sine of arg |
cos | variable to take cosine of arg |
FE_INVALID | for signaling NaN or infinity |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Hyperbolic sine. This function is exact to rounding for all rounding modes.
See also: Documentation for std::sinh.
arg | function argument |
FE_INVALID | for signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Square root. This function is exact to rounding for all rounding modes.
See also: Documentation for std::sqrt.
arg | function argument |
FE_INVALID | for signaling NaN and negative arguments |
FE_INEXACT | according to rounding |
Tangent function. This function is exact to rounding for all rounding modes.
See also: Documentation for std::tan.
arg | function argument |
FE_INVALID | for signaling NaN or infinity |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Hyperbolic tangent. This function is exact to rounding for all rounding modes.
See also: Documentation for std::tanh.
arg | function argument |
FE_INVALID | for signaling NaN |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
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.
arg | function argument |
FE_INVALID | for signaling NaN, negative infinity or negative integer arguments |
FE_DIVBYZERO | for 0 |
FE_OVERFLOW,...UNDERFLOW,...INEXACT | according to rounding |
Nearest integer not greater in magnitude than half value. See also: Documentation for std::trunc.
arg | half to round |
FE_INVALID | for signaling NaN |
FE_INEXACT | if value had to be rounded |
|
private |
|
staticprivate |