Next: Comparison Functions, Previous: Conversion Functions, Up: MPFR Interface [Index]
Set rop to op1 + op2 rounded in the direction
rnd. The IEEE 754 rules are used, in particular for signed zeros.
But for types having no signed zeros, 0 is considered unsigned
(i.e., (+0) + 0 = (+0) and (−0) + 0 = (−0)).
The mpfr_add_d
function assumes that the radix of the double
type
is a power of 2, with a precision at most that declared by the C implementation
(macro IEEE_DBL_MANT_DIG
, and if not defined 53 bits).
Set rop to op1 - op2 rounded in the direction
rnd. The IEEE 754 rules are used, in particular for signed zeros.
But for types having no signed zeros, 0 is considered unsigned
(i.e., (+0) − 0 = (+0), (−0) − 0 = (−0),
0 − (+0) = (−0) and 0 − (−0) = (+0)).
The same restrictions than for mpfr_add_d
apply to mpfr_d_sub
and mpfr_sub_d
.
Set rop to op1 times op2 rounded in the
direction rnd.
When a result is zero, its sign is the product of the signs of the operands
(for types having no signed zeros, 0 is considered positive).
The same restrictions than for mpfr_add_d
apply to mpfr_mul_d
.
Set rop to the square of op rounded in the direction rnd.
Set rop to op1/op2 rounded in the direction rnd.
When a result is zero, its sign is the product of the signs of the operands.
For types having no signed zeros, 0 is considered positive; but note that if
op1 is non-zero and op2 is zero, the result might change from
±Inf to NaN in future MPFR versions if there is an opposite decision
on the IEEE 754 side.
The same restrictions than for mpfr_add_d
apply to mpfr_d_div
and mpfr_div_d
.
Set rop to the square root of op rounded in the direction rnd. Set rop to −0 if op is −0, to be consistent with the IEEE 754 standard. Set rop to NaN if op is negative.
Set rop to the reciprocal square root of op rounded in the direction rnd. Set rop to +Inf if op is ±0, +0 if op is +Inf, and NaN if op is negative. Warning! Therefore the result on −0 is different from the one of the rSqrt function recommended by the IEEE 754-2008 standard (Section 9.2.1), which is −Inf instead of +Inf.
Set rop to the cubic root (resp. the kth root) of op rounded in the direction rnd. For k = 0, set rop to NaN. For k odd (resp. even) and op negative (including −Inf), set rop to a negative number (resp. NaN). If op is zero, set rop to zero with the sign obtained by the usual limit rules, i.e., the same sign as op if k is odd, and positive if k is even.
These functions agree with the rootn function of the IEEE 754-2008 standard (Section 9.2).
This function is the same as mpfr_rootn_ui
except when op
is −0 and k is even: the result is −0 instead of +0
(the reason was to be consistent with mpfr_sqrt
). Said otherwise,
if op is zero, set rop to op.
This function predates the IEEE 754-2008 standard and behaves differently from its rootn function. It is marked as deprecated and will be removed in a future release.
Set rop to op1 raised to op2,
rounded in the direction rnd.
Special values are handled as described in the ISO C99 and IEEE 754-2008
standards for the pow
function:
pow(±0, y)
returns plus or minus infinity for y a negative odd integer.
pow(±0, y)
returns plus infinity for y negative and not an odd integer.
pow(±0, y)
returns plus or minus zero for y a positive odd integer.
pow(±0, y)
returns plus zero for y positive and not an odd integer.
pow(-1, ±Inf)
returns 1.
pow(+1, y)
returns 1 for any y, even a NaN.
pow(x, ±0)
returns 1 for any x, even a NaN.
pow(x, y)
returns NaN for finite negative x and finite non-integer y.
pow(x, -Inf)
returns plus infinity for 0 < abs(x) < 1, and plus zero for abs(x) > 1.
pow(x, +Inf)
returns plus zero for 0 < abs(x) < 1, and plus infinity for abs(x) > 1.
pow(-Inf, y)
returns minus zero for y a negative odd integer.
pow(-Inf, y)
returns plus zero for y negative and not an odd integer.
pow(-Inf, y)
returns minus infinity for y a positive odd integer.
pow(-Inf, y)
returns plus infinity for y positive and not an odd integer.
pow(+Inf, y)
returns plus zero for y negative, and plus infinity for y positive.
Note: When 0 is of integer type, it is regarded as +0 by these functions.
We do not use the usual limit rules in this case, as these rules are not
used for pow
.
Set rop to -op and the absolute value of op respectively, rounded in the direction rnd. Just changes or adjusts the sign if rop and op are the same variable, otherwise a rounding might occur if the precision of rop is less than that of op.
The sign rule also applies to NaN in order to mimic the IEEE 754
negate
and abs
operations, i.e., for mpfr_neg
, the
sign is reversed, and for mpfr_abs
, the sign is set to positive.
But contrary to IEEE 754, the NaN flag is set as usual.
Set rop to the positive difference of op1 and op2, i.e., op1 - op2 rounded in the direction rnd if op1 > op2, +0 if op1 <= op2, and NaN if op1 or op2 is NaN.
Set rop to op1 times 2 raised to op2 rounded in the direction rnd. Just increases the exponent by op2 when rop and op1 are identical.
Set rop to op1 divided by 2 raised to op2 rounded in the direction rnd. Just decreases the exponent by op2 when rop and op1 are identical.
Next: Comparison Functions, Previous: Conversion Functions, Up: MPFR Interface [Index]