简体   繁体   中英

Can I use a `mpfr_t` as both input and output argument?

The question is very simple and direct, but I could not find an answer on the documentation . If I have

mpfr_t a, b;

Can I do something like

mpfr_add(a, a, b, rnd);

This would compute the sum of a and b and store the result on a . I don't know if this results in an aliasing problem, potentially invalidating the result, or if this is fine.

Never mind, it's in section 4.3 of the linked document.

MPFR allows you to use the same variable for both input and output in the same expression. For example, the main function for floating-point multiplication, mpfr_mul, can be used like this: mpfr_mul (x, x, x, rnd). This computes the square of x with rounding mode rnd and puts the result back in x.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM