티스토리 수익 글 보기
|
half
2.2
IEEE 754-based half-precision floating-point library
|
Main namespace for half-precision functionality. More…
Namespaces | |
| literal | |
| Library-defined half-precision literals. | |
Classes | |
| class | half |
| Half-precision floating-point type. More… | |
Functions | |
Comparison operators | |
| constexpr bool | operator== (half x, half y) |
| Comparison for equality. More… | |
| constexpr bool | operator!= (half x, half y) |
| Comparison for inequality. More… | |
| constexpr bool | operator< (half x, half y) |
| Comparison for less than. More… | |
| constexpr bool | operator> (half x, half y) |
| Comparison for greater than. More… | |
| constexpr bool | operator<= (half x, half y) |
| Comparison for less equal. More… | |
| constexpr bool | operator>= (half x, half y) |
| Comparison for greater equal. More… | |
Arithmetic operators | |
| constexpr half | operator+ (half arg) |
| Identity. More… | |
| constexpr half | operator- (half arg) |
| Negation. More… | |
| half | operator+ (half x, half y) |
| Addition. More… | |
| half | operator- (half x, half y) |
| Subtraction. More… | |
| half | operator* (half x, half y) |
| Multiplication. More… | |
| half | operator/ (half x, half y) |
| Division. More… | |
Input and output | |
| template<typename charT , typename traits > | |
| std::basic_ostream< charT, traits > & | operator<< (std::basic_ostream< charT, traits > &out, half arg) |
| Output operator. More… | |
| template<typename charT , typename traits > | |
| std::basic_istream< charT, traits > & | operator>> (std::basic_istream< charT, traits > &in, half &arg) |
| Input operator. More… | |
Basic mathematical operations | |
| constexpr half | fabs (half arg) |
| Absolute value. More… | |
| constexpr half | abs (half arg) |
| Absolute value. More… | |
| half | fmod (half x, half y) |
| Remainder of division. More… | |
| half | remainder (half x, half y) |
| Remainder of division. More… | |
| half | remquo (half x, half y, int *quo) |
| Remainder of division. More… | |
| half | fma (half x, half y, half z) |
| Fused multiply add. More… | |
| constexpr half | fmax (half x, half y) |
| Maximum of half expressions. More… | |
| constexpr half | fmin (half x, half y) |
| Minimum of half expressions. More… | |
| half | fdim (half x, half y) |
| Positive difference. More… | |
| half | nanh (const char *arg) |
| Get NaN value. More… | |
Exponential functions | |
| half | exp (half arg) |
| Exponential function. More… | |
| half | exp2 (half arg) |
| Binary exponential. More… | |
| half | expm1 (half arg) |
| Exponential minus one. More… | |
| half | log (half arg) |
| Natural logarithm. More… | |
| half | log10 (half arg) |
| Common logarithm. More… | |
| half | log2 (half arg) |
| Binary logarithm. More… | |
| half | log1p (half arg) |
| Natural logarithm plus one. More… | |
Power functions | |
| half | sqrt (half arg) |
| Square root. More… | |
| half | rsqrt (half arg) |
| Inverse square root. More… | |
| half | cbrt (half arg) |
| Cubic root. More… | |
| half | hypot (half x, half y) |
| Hypotenuse function. More… | |
| half | hypot (half x, half y, half z) |
| Hypotenuse function. More… | |
| half | pow (half x, half y) |
| Power function. More… | |
Trigonometric functions | |
| void | sincos (half arg, half *sin, half *cos) |
| Compute sine and cosine simultaneously. More… | |
| half | sin (half arg) |
| Sine function. More… | |
| half | cos (half arg) |
| Cosine function. More… | |
| half | tan (half arg) |
| Tangent function. More… | |
| half | asin (half arg) |
| Arc sine. More… | |
| half | acos (half arg) |
| Arc cosine function. More… | |
| half | atan (half arg) |
| Arc tangent function. More… | |
| half | atan2 (half y, half x) |
| Arc tangent function. More… | |
Hyperbolic functions | |
| half | sinh (half arg) |
| Hyperbolic sine. More… | |
| half | cosh (half arg) |
| Hyperbolic cosine. More… | |
| half | tanh (half arg) |
| Hyperbolic tangent. More… | |
| half | asinh (half arg) |
| Hyperbolic area sine. More… | |
| half | acosh (half arg) |
| Hyperbolic area cosine. More… | |
| half | atanh (half arg) |
| Hyperbolic area tangent. More… | |
Error and gamma functions | |
| half | erf (half arg) |
| Error function. More… | |
| half | erfc (half arg) |
| Complementary error function. More… | |
| half | lgamma (half arg) |
| Natural logarithm of gamma function. More… | |
| half | tgamma (half arg) |
| Gamma function. More… | |
Rounding | |
| half | ceil (half arg) |
| Nearest integer not less than half value. More… | |
| half | floor (half arg) |
| Nearest integer not greater than half value. More… | |
| half | trunc (half arg) |
| Nearest integer not greater in magnitude than half value. More… | |
| half | round (half arg) |
| Nearest integer. More… | |
| long | lround (half arg) |
| Nearest integer. More… | |
| half | rint (half arg) |
| Nearest integer using half’s internal rounding mode. More… | |
| long | lrint (half arg) |
| Nearest integer using half’s internal rounding mode. More… | |
| half | nearbyint (half arg) |
| Nearest integer using half’s internal rounding mode. More… | |
| long long | llround (half arg) |
| Nearest integer. More… | |
| long long | llrint (half arg) |
| Nearest integer using half’s internal rounding mode. More… | |
Floating point manipulation | |
| half | frexp (half arg, int *exp) |
| Decompress floating-point number. More… | |
| half | scalbln (half arg, long exp) |
| Multiply by power of two. More… | |
| half | scalbn (half arg, int exp) |
| Multiply by power of two. More… | |
| half | ldexp (half arg, int exp) |
| Multiply by power of two. More… | |
| half | modf (half arg, half *iptr) |
| Extract integer and fractional parts. More… | |
| int | ilogb (half arg) |
| Extract exponent. More… | |
| half | logb (half arg) |
| Extract exponent. More… | |
| half | nextafter (half from, half to) |
| Next representable value. More… | |
| half | nexttoward (half from, long double to) |
| Next representable value. More… | |
| constexpr half | copysign (half x, half y) |
| Take sign. More… | |
Floating point classification | |
| constexpr int | fpclassify (half arg) |
| Classify floating-point value. More… | |
| constexpr bool | isfinite (half arg) |
| Check if finite number. More… | |
| constexpr bool | isinf (half arg) |
| Check for infinity. More… | |
| constexpr bool | isnan (half arg) |
| Check for NaN. More… | |
| constexpr bool | isnormal (half arg) |
| Check if normal number. More… | |
| constexpr bool | signbit (half arg) |
| Check sign. More… | |
Comparison | |
| constexpr bool | isgreater (half x, half y) |
| Quiet comparison for greater than. More… | |
| constexpr bool | isgreaterequal (half x, half y) |
| Quiet comparison for greater equal. More… | |
| constexpr bool | isless (half x, half y) |
| Quiet comparison for less than. More… | |
| constexpr bool | islessequal (half x, half y) |
| Quiet comparison for less equal. More… | |
| constexpr bool | islessgreater (half x, half y) |
| Quiet comarison for less or greater. More… | |
| constexpr bool | isunordered (half x, half y) |
| Quiet check if unordered. More… | |
Casting | |
| template<typename T , typename U > | |
| T | half_cast (U arg) |
| Cast to or from half-precision floating-point number. More… | |
| template<typename T , std::float_round_style R, typename U > | |
| T | half_cast (U arg) |
| Cast to or from half-precision floating-point number. More… | |
Error handling | |
| int | feclearexcept (int excepts) |
| Clear exception flags. More… | |
| int | fetestexcept (int excepts) |
| Test exception flags. More… | |
| int | feraiseexcept (int excepts) |
| Raise exception flags. More… | |
| int | fegetexceptflag (int *flagp, int excepts) |
| Save exception flags. More… | |
| int | fesetexceptflag (const int *flagp, int excepts) |
| Restore exception flags. More… | |
| void | fethrowexcept (int excepts, const char *msg="") |
| Throw C++ exceptions based on set exception flags. More… | |
Detailed Description
Main namespace for half-precision functionality.
This namespace contains all the functionality provided by the library.
Function Documentation
◆ operator==()
Comparison for equality.
- Parameters
-
x first operand y second operand
- Return values
-
true if operands equal false else
- Exceptions
-
FE_INVALID if x or y is NaN
◆ operator!=()
Comparison for inequality.
- Parameters
-
x first operand y second operand
- Return values
-
true if operands not equal false else
- Exceptions
-
FE_INVALID if x or y is NaN
◆ operator<()
Comparison for less than.
- Parameters
-
x first operand y second operand
- Return values
-
true if x less than y false else
- Exceptions
-
FE_INVALID if x or y is NaN
◆ operator>()
Comparison for greater than.
- Parameters
-
x first operand y second operand
- Return values
-
true if x greater than y false else
- Exceptions
-
FE_INVALID if x or y is NaN
◆ operator<=()
Comparison for less equal.
- Parameters
-
x first operand y second operand
- Return values
-
true if x less equal y false else
- Exceptions
-
FE_INVALID if x or y is NaN
◆ operator>=()
Comparison for greater equal.
- Parameters
-
x first operand y second operand
- Return values
-
true if x greater equal y false else
- Exceptions
-
FE_INVALID if x or y is NaN
◆ operator+() [1/2]
Identity.
- Parameters
-
arg operand
- Returns
- unchanged operand
◆ operator-() [1/2]
Negation.
- Parameters
-
arg operand
- Returns
- negated operand
◆ operator+() [2/2]
Addition.
This operation is exact to rounding for all rounding modes.
- Parameters
-
x left operand y right operand
- Returns
- sum of half expressions
- Exceptions
-
FE_INVALID if x and y are infinities with different signs or signaling NaNs FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ operator-() [2/2]
Subtraction.
This operation is exact to rounding for all rounding modes.
- Parameters
-
x left operand y right operand
- Returns
- difference of half expressions
- Exceptions
-
FE_INVALID if x and y are infinities with equal signs or signaling NaNs FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ operator*()
Multiplication.
This operation is exact to rounding for all rounding modes.
- Parameters
-
x left operand y right operand
- Returns
- product of half expressions
- Exceptions
-
FE_INVALID if multiplying 0 with infinity or if x or y is signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ operator/()
Division.
This operation is exact to rounding for all rounding modes.
- Parameters
-
x left operand y right operand
- Returns
- quotient of half expressions
- Exceptions
-
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
◆ operator<<()
| std::basic_ostream<charT,traits>& half_float::operator<< | ( | std::basic_ostream< charT, traits > & | out, |
| half | arg | ||
| ) |
Output operator.
This uses the built-in functionality for streaming out floating-point numbers.
- Parameters
-
out output stream to write into arg half expression to write
- Returns
- reference to output stream
◆ operator>>()
| std::basic_istream<charT,traits>& half_float::operator>> | ( | std::basic_istream< charT, traits > & | in, |
| half & | arg | ||
| ) |
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
-
in input stream to read from arg half to read into
- Returns
- reference to input stream
- Exceptions
-
FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ fabs()
Absolute value.
See also: Documentation for std::fabs.
- Parameters
-
arg operand
- Returns
- absolute value of arg
◆ abs()
Absolute value.
See also: Documentation for std::abs.
- Parameters
-
arg operand
- Returns
- absolute value of arg
◆ fmod()
Remainder of division.
See also: Documentation for std::fmod.
- Parameters
-
x first operand y second operand
- Returns
- remainder of floating-point division.
- Exceptions
-
FE_INVALID if x is infinite or y is 0 or if x or y is signaling NaN
◆ remainder()
Remainder of division.
See also: Documentation for std::remainder.
- Parameters
-
x first operand y second operand
- Returns
- remainder of floating-point division.
- Exceptions
-
FE_INVALID if x is infinite or y is 0 or if x or y is signaling NaN
◆ remquo()
Remainder of division.
See also: Documentation for std::remquo.
- Parameters
-
x first operand y second operand quo address to store some bits of quotient at
- Returns
- remainder of floating-point division.
- Exceptions
-
FE_INVALID if x is infinite or y is 0 or if x or y is signaling NaN
◆ fma()
Fused multiply add.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::fma.
- Parameters
-
x first operand y second operand z third operand
- Returns
- ( x * y ) + z rounded as one operation.
- Exceptions
-
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
◆ fmax()
Maximum of half expressions.
See also: Documentation for std::fmax.
- Parameters
-
x first operand y second operand
- Returns
- maximum of operands, ignoring quiet NaNs
- Exceptions
-
FE_INVALID if x or y is signaling NaN
◆ fmin()
Minimum of half expressions.
See also: Documentation for std::fmin.
- Parameters
-
x first operand y second operand
- Returns
- minimum of operands, ignoring quiet NaNs
- Exceptions
-
FE_INVALID if x or y is signaling NaN
◆ fdim()
Positive difference.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::fdim.
- Parameters
-
x first operand y second operand
- Returns
- x – y or 0 if difference negative
- Exceptions
-
FE_… according to operator-(half,half)
◆ nanh()
|
inline |
◆ exp()
Exponential function.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::exp.
- Parameters
-
arg function argument
- Returns
- e raised to arg
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ exp2()
Binary exponential.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::exp2.
- Parameters
-
arg function argument
- Returns
- 2 raised to arg
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ expm1()
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
-
arg function argument
- Returns
- e raised to arg and subtracted by 1
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ log()
Natural logarithm.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::log.
- Parameters
-
arg function argument
- Returns
- logarithm of arg to base e
- Exceptions
-
FE_INVALID for signaling NaN or negative argument FE_DIVBYZERO for 0 FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ log10()
Common logarithm.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::log10.
- Parameters
-
arg function argument
- Returns
- logarithm of arg to base 10
- Exceptions
-
FE_INVALID for signaling NaN or negative argument FE_DIVBYZERO for 0 FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ log2()
Binary logarithm.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::log2.
- Parameters
-
arg function argument
- Returns
- logarithm of arg to base 2
- Exceptions
-
FE_INVALID for signaling NaN or negative argument FE_DIVBYZERO for 0 FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ log1p()
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
-
arg function argument
- Returns
- logarithm of arg plus 1 to base e
- Exceptions
-
FE_INVALID for signaling NaN or argument <-1 FE_DIVBYZERO for -1 FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ sqrt()
Square root.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::sqrt.
- Parameters
-
arg function argument
- Returns
- square root of arg
- Exceptions
-
FE_INVALID for signaling NaN and negative arguments FE_INEXACT according to rounding
◆ rsqrt()
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.
- Parameters
-
arg function argument
- Returns
- reciprocal of square root of arg
- Exceptions
-
FE_INVALID for signaling NaN and negative arguments FE_INEXACT according to rounding
◆ cbrt()
Cubic root.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::cbrt.
- Parameters
-
arg function argument
- Returns
- cubic root of arg
- Exceptions
-
FE_INVALID for signaling NaN FE_INEXACT according to rounding
◆ hypot() [1/2]
Hypotenuse function.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::hypot.
- Parameters
-
x first argument y second argument
- Returns
- square root of sum of squares without internal over- or underflows
- Exceptions
-
FE_INVALID if x or y is signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding of the final square root
◆ hypot() [2/2]
Hypotenuse function.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::hypot.
- Parameters
-
x first argument y second argument z third argument
- Returns
- square root of sum of squares without internal over- or underflows
- Exceptions
-
FE_INVALID if x, y or z is signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding of the final square root
◆ pow()
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
-
x base y exponent
- Returns
- x raised to y
- Exceptions
-
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
◆ sincos()
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
-
arg function argument sin variable to take sine of arg cos variable to take cosine of arg
- Exceptions
-
FE_INVALID for signaling NaN or infinity FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ sin()
Sine function.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::sin.
- Parameters
-
arg function argument
- Returns
- sine value of arg
- Exceptions
-
FE_INVALID for signaling NaN or infinity FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ cos()
Cosine function.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::cos.
- Parameters
-
arg function argument
- Returns
- cosine value of arg
- Exceptions
-
FE_INVALID for signaling NaN or infinity FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ tan()
Tangent function.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::tan.
- Parameters
-
arg function argument
- Returns
- tangent value of arg
- Exceptions
-
FE_INVALID for signaling NaN or infinity FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ asin()
Arc sine.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::asin.
- Parameters
-
arg function argument
- Returns
- arc sine value of arg
- Exceptions
-
FE_INVALID for signaling NaN or if abs(arg) > 1 FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ acos()
Arc cosine function.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::acos.
- Parameters
-
arg function argument
- Returns
- arc cosine value of arg
- Exceptions
-
FE_INVALID for signaling NaN or if abs(arg) > 1 FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ atan()
Arc tangent function.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::atan.
- Parameters
-
arg function argument
- Returns
- arc tangent value of arg
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ atan2()
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
-
y numerator x denominator
- Returns
- arc tangent value
- Exceptions
-
FE_INVALID if x or y is signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ sinh()
Hyperbolic sine.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::sinh.
- Parameters
-
arg function argument
- Returns
- hyperbolic sine value of arg
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ cosh()
Hyperbolic cosine.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::cosh.
- Parameters
-
arg function argument
- Returns
- hyperbolic cosine value of arg
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ tanh()
Hyperbolic tangent.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::tanh.
- Parameters
-
arg function argument
- Returns
- hyperbolic tangent value of arg
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ asinh()
Hyperbolic area sine.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::asinh.
- Parameters
-
arg function argument
- Returns
- area sine value of arg
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ acosh()
Hyperbolic area cosine.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::acosh.
- Parameters
-
arg function argument
- Returns
- area cosine value of arg
- Exceptions
-
FE_INVALID for signaling NaN or arguments <1 FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ atanh()
Hyperbolic area tangent.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::atanh.
- Parameters
-
arg function argument
- Returns
- area tangent value of arg
- Exceptions
-
FE_INVALID for signaling NaN or if abs(arg) > 1 FE_DIVBYZERO for +/-1 FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ erf()
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
-
arg function argument
- Returns
- error function value of arg
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ erfc()
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
-
arg function argument
- Returns
- 1 minus error function value of arg
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ lgamma()
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
-
arg function argument
- Returns
- natural logarith of gamma function for arg
- Exceptions
-
FE_INVALID for signaling NaN FE_DIVBYZERO for 0 or negative integer arguments FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ tgamma()
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
-
arg function argument
- Returns
- gamma function value of arg
- Exceptions
-
FE_INVALID for signaling NaN, negative infinity or negative integer arguments FE_DIVBYZERO for 0 FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ ceil()
Nearest integer not less than half value.
See also: Documentation for std::ceil.
- Parameters
-
arg half to round
- Returns
- nearest integer not less than arg
- Exceptions
-
FE_INVALID for signaling NaN FE_INEXACT if value had to be rounded
◆ floor()
Nearest integer not greater than half value.
See also: Documentation for std::floor.
- Parameters
-
arg half to round
- Returns
- nearest integer not greater than arg
- Exceptions
-
FE_INVALID for signaling NaN FE_INEXACT if value had to be rounded
◆ trunc()
Nearest integer not greater in magnitude than half value.
See also: Documentation for std::trunc.
- Parameters
-
arg half to round
- Returns
- nearest integer not greater in magnitude than arg
- Exceptions
-
FE_INVALID for signaling NaN FE_INEXACT if value had to be rounded
◆ round()
Nearest integer.
See also: Documentation for std::round.
- Parameters
-
arg half to round
- Returns
- nearest integer, rounded away from zero in half-way cases
- Exceptions
-
FE_INVALID for signaling NaN FE_INEXACT if value had to be rounded
◆ lround()
|
inline |
Nearest integer.
See also: Documentation for std::lround.
- Parameters
-
arg half to round
- Returns
- nearest integer, rounded away from zero in half-way cases
- Exceptions
-
FE_INVALID if value is not representable as long
◆ rint()
Nearest integer using half’s internal rounding mode.
See also: Documentation for std::rint.
- Parameters
-
arg half expression to round
- Returns
- nearest integer using default rounding mode
- Exceptions
-
FE_INVALID for signaling NaN FE_INEXACT if value had to be rounded
◆ lrint()
|
inline |
Nearest integer using half’s internal rounding mode.
See also: Documentation for std::lrint.
- Parameters
-
arg half expression to round
- Returns
- nearest integer using default rounding mode
- Exceptions
-
FE_INVALID if value is not representable as longFE_INEXACT if value had to be rounded
◆ nearbyint()
Nearest integer using half’s internal rounding mode.
See also: Documentation for std::nearbyint.
- Parameters
-
arg half expression to round
- Returns
- nearest integer using default rounding mode
- Exceptions
-
FE_INVALID for signaling NaN
◆ llround()
|
inline |
Nearest integer.
See also: Documentation for std::llround.
- Parameters
-
arg half to round
- Returns
- nearest integer, rounded away from zero in half-way cases
- Exceptions
-
FE_INVALID if value is not representable as long long
◆ llrint()
|
inline |
Nearest integer using half’s internal rounding mode.
See also: Documentation for std::llrint.
- Parameters
-
arg half expression to round
- Returns
- nearest integer using default rounding mode
- Exceptions
-
FE_INVALID if value is not representable as long longFE_INEXACT if value had to be rounded
◆ frexp()
Decompress floating-point number.
See also: Documentation for std::frexp.
- Parameters
-
arg number to decompress exp address to store exponent at
- Returns
- significant in range [0.5, 1)
- Exceptions
-
FE_INVALID for signaling NaN
◆ scalbln()
Multiply by power of two.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::scalbln.
- Parameters
-
arg number to modify exp power of two to multiply with
- Returns
- arg multplied by 2 raised to exp
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ scalbn()
Multiply by power of two.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::scalbn.
- Parameters
-
arg number to modify exp power of two to multiply with
- Returns
- arg multplied by 2 raised to exp
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ ldexp()
Multiply by power of two.
This function is exact to rounding for all rounding modes.
See also: Documentation for std::ldexp.
- Parameters
-
arg number to modify exp power of two to multiply with
- Returns
- arg multplied by 2 raised to exp
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ modf()
Extract integer and fractional parts.
See also: Documentation for std::modf.
- Parameters
-
arg number to decompress iptr address to store integer part at
- Returns
- fractional part
- Exceptions
-
FE_INVALID for signaling NaN
◆ ilogb()
|
inline |
Extract exponent.
See also: Documentation for std::ilogb.
- Parameters
-
arg number to query
- Returns
- floating-point exponent
- Return values
-
FP_ILOGB0 for zero FP_ILOGBNAN for NaN INT_MAX for infinity
- Exceptions
-
FE_INVALID for 0 or infinite values
◆ logb()
Extract exponent.
See also: Documentation for std::logb.
- Parameters
-
arg number to query
- Returns
- floating-point exponent
- Exceptions
-
FE_INVALID for signaling NaN FE_DIVBYZERO for 0
◆ nextafter()
Next representable value.
See also: Documentation for std::nextafter.
- Parameters
-
from value to compute next representable value for to direction towards which to compute next value
- Returns
- next representable value after from in direction towards to
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW for infinite result from finite argument FE_UNDERFLOW for subnormal result
◆ nexttoward()
Next representable value.
See also: Documentation for std::nexttoward.
- Parameters
-
from value to compute next representable value for to direction towards which to compute next value
- Returns
- next representable value after from in direction towards to
- Exceptions
-
FE_INVALID for signaling NaN FE_OVERFLOW for infinite result from finite argument FE_UNDERFLOW for subnormal result
◆ copysign()
Take sign.
See also: Documentation for std::copysign.
- Parameters
-
x value to change sign for y value to take sign from
- Returns
- value equal to x in magnitude and to y in sign
◆ fpclassify()
|
inlineconstexpr |
Classify floating-point value.
See also: Documentation for std::fpclassify.
- Parameters
-
arg number to classify
- Return values
-
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
◆ isfinite()
|
inlineconstexpr |
Check if finite number.
See also: Documentation for std::isfinite.
- Parameters
-
arg number to check
- Return values
-
true if neither infinity nor NaN false else
◆ isinf()
|
inlineconstexpr |
Check for infinity.
See also: Documentation for std::isinf.
- Parameters
-
arg number to check
- Return values
-
true for positive or negative infinity false else
◆ isnan()
|
inlineconstexpr |
Check for NaN.
See also: Documentation for std::isnan.
- Parameters
-
arg number to check
- Return values
-
true for NaNs false else
◆ isnormal()
|
inlineconstexpr |
Check if normal number.
See also: Documentation for std::isnormal.
- Parameters
-
arg number to check
- Return values
-
true if normal number false if either subnormal, zero, infinity or NaN
◆ signbit()
|
inlineconstexpr |
Check sign.
See also: Documentation for std::signbit.
- Parameters
-
arg number to check
- Return values
-
true for negative number false for positive number
◆ isgreater()
Quiet comparison for greater than.
See also: Documentation for std::isgreater.
- Parameters
-
x first operand y second operand
- Return values
-
true if x greater than y false else
◆ isgreaterequal()
Quiet comparison for greater equal.
See also: Documentation for std::isgreaterequal.
- Parameters
-
x first operand y second operand
- Return values
-
true if x greater equal y false else
◆ isless()
Quiet comparison for less than.
See also: Documentation for std::isless.
- Parameters
-
x first operand y second operand
- Return values
-
true if x less than y false else
◆ islessequal()
Quiet comparison for less equal.
See also: Documentation for std::islessequal.
- Parameters
-
x first operand y second operand
- Return values
-
true if x less equal y false else
◆ islessgreater()
Quiet comarison for less or greater.
See also: Documentation for std::islessgreater.
- Parameters
-
x first operand y second operand
- Return values
-
true if either less or greater false else
◆ isunordered()
Quiet check if unordered.
See also: Documentation for std::isunordered.
- Parameters
-
x first operand y second operand
- Return values
-
true if unordered (one or two NaN operands) false else
◆ half_cast() [1/2]
| T half_float::half_cast | ( | U | arg | ) |
Cast to or from half-precision floating-point number.
This casts between half and any built-in arithmetic type. The values are converted directly using the default rounding mode, without any roundtrip over float that a static_cast would otherwise do.
Using this cast with neither of the two types being a half or with any of the two types not being a built-in arithmetic type (apart from half, of course) results in a compiler error and casting between halfs returns the argument unmodified.
- Template Parameters
-
T destination type (half or built-in arithmetic type) U source type (half or built-in arithmetic type)
- Parameters
-
arg value to cast
- Returns
- arg converted to destination type
- Exceptions
-
FE_INVALID if T is integer type and result is not representable as T FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ half_cast() [2/2]
| T half_float::half_cast | ( | U | arg | ) |
Cast to or from half-precision floating-point number.
This casts between half and any built-in arithmetic type. The values are converted directly using the specified rounding mode, without any roundtrip over float that a static_cast would otherwise do.
Using this cast with neither of the two types being a half or with any of the two types not being a built-in arithmetic type (apart from half, of course) results in a compiler error and casting between halfs returns the argument unmodified.
- Template Parameters
-
T destination type (half or built-in arithmetic type) R rounding mode to use. U source type (half or built-in arithmetic type)
- Parameters
-
arg value to cast
- Returns
- arg converted to destination type
- Exceptions
-
FE_INVALID if T is integer type and result is not representable as T FE_OVERFLOW,…UNDERFLOW,…INEXACT according to rounding
◆ feclearexcept()
|
inline |
Clear exception flags.
This function works even if automatic exception flag handling is disabled, but in that case manual flag management is the only way to raise flags.
See also: Documentation for std::feclearexcept.
- Parameters
-
excepts OR of exceptions to clear
- Return values
-
0 all selected flags cleared successfully
◆ fetestexcept()
|
inline |
Test exception flags.
This function works even if automatic exception flag handling is disabled, but in that case manual flag management is the only way to raise flags.
See also: Documentation for std::fetestexcept.
- Parameters
-
excepts OR of exceptions to test
- Returns
- OR of selected exceptions if raised
◆ feraiseexcept()
|
inline |
Raise exception flags.
This raises the specified floating point exceptions and also invokes any additional automatic exception handling as configured with the HALF_ERRHANDLIG_… preprocessor symbols. This function works even if automatic exception flag handling is disabled, but in that case manual flag management is the only way to raise flags.
See also: Documentation for std::feraiseexcept.
- Parameters
-
excepts OR of exceptions to raise
- Return values
-
0 all selected exceptions raised successfully
◆ fegetexceptflag()
|
inline |
Save exception flags.
This function works even if automatic exception flag handling is disabled, but in that case manual flag management is the only way to raise flags.
See also: Documentation for std::fegetexceptflag.
- Parameters
-
flagp adress to store flag state at excepts OR of flags to save
- Return values
-
0 for success
◆ fesetexceptflag()
|
inline |
Restore exception flags.
This only copies the specified exception state (including unset flags) without incurring any additional exception handling. This function works even if automatic exception flag handling is disabled, but in that case manual flag management is the only way to raise flags.
See also: Documentation for std::fesetexceptflag.
- Parameters
-
flagp adress to take flag state from excepts OR of flags to restore
- Return values
-
0 for success
◆ fethrowexcept()
|
inline |
Throw C++ exceptions based on set exception flags.
This function manually throws a corresponding C++ exception if one of the specified flags is set, no matter if automatic throwing (via HALF_ERRHANDLING_THROW_…) is enabled or not. This function works even if automatic exception flag handling is disabled, but in that case manual flag management is the only way to raise flags.
- Parameters
-
excepts OR of exceptions to test msg error message to use for exception description
- Exceptions
-
std::domain_error if FE_INVALIDorFE_DIVBYZEROis selected and setstd::overflow_error if FE_OVERFLOWis selected and setstd::underflow_error if FE_UNDERFLOWis selected and setstd::range_error if FE_INEXACTis selected and set