There are some operations that are too complicated or expensive to perform by hand on floating-point numbers. ISO C99 defines functions to do these operations, which mostly involve changing single bits.
copysign
never raises an exception.
This function is defined in IEC 559 (and the appendix with recommended functions in IEEE 754/IEEE 854).
signbit
is a generic macro which can work on all floating-point
types. It returns a nonzero value if the value of x has its sign
bit set.
This is not the same as x < 0.0
, because IEEE 754 floating
point allows zero to be signed. The comparison -0.0 < 0.0
is
false, but signbit (-0.0)
will return a nonzero value.
nextafter
function returns the next representable neighbor of
x in the direction towards y. The size of the step between
x and the result depends on the type of the result. If
@math{x = y} the function simply returns y. If either
value is NaN
, NaN
is returned. Otherwise
a value corresponding to the value of the least significant bit in the
mantissa is added or subtracted, depending on the direction.
nextafter
will signal overflow or underflow if the result goes
outside of the range of normalized numbers.
This function is defined in IEC 559 (and the appendix with recommended functions in IEEE 754/IEEE 854).
nextafter
except that their second argument is a long
double
.
nan
function returns a representation of NaN, provided that
NaN is supported by the target platform.
nan ("n-char-sequence")
is equivalent to
strtod ("NAN(n-char-sequence)")
.
The argument tagp is used in an unspecified manner. On IEEE 754 systems, there are many representations of NaN, and tagp selects one. On other systems it may do nothing.
Go to the first, previous, next, last section, table of contents.