Can I use `mpfr_t` as an input and output argument?

The question is very simple and direct, but I could not find the answer in the documentation . if I have

mpfr_t a, b; 

Can i do something like

 mpfr_add(a, a, b, rnd); 

This will calculate the sum of a and b and store the result on a . I do not know if this leads to a smoothing problem, which can lead to invalidation of the result or if it is normal.

+6
source share
1 answer

Nothing, this is in section 4.3 of the linked document.

MPFR allows you to use the same variable for input and output in a single expression. For example, the main function for floating point multiplication, mpfr_mul, can be used as follows: mpfr_mul (x, x, x, rnd). This computes the square x with the rounding mode rnd and returns the result in x.

+3
source

Source: https://habr.com/ru/post/1015243/


All Articles