A simple question: why there is no mpfr_sub_sj (while there is mpfr_set_sj_2exp)?
More details: for mpfr_set_xx_2exp there are sj and uj variants:
$ grep -P 'int mpfr_set_.*_2exp' mpfr.h
__MPFR_DECLSPEC int mpfr_set_z_2exp (mpfr_ptr, mpz_srcptr, mpfr_exp_t,
__MPFR_DECLSPEC int mpfr_set_si_2exp (mpfr_ptr, long, mpfr_exp_t, mpfr_rnd_t);
__MPFR_DECLSPEC int mpfr_set_ui_2exp (mpfr_ptr, unsigned long, mpfr_exp_t,
__MPFR_DECLSPEC int mpfr_set_sj_2exp (mpfr_ptr, intmax_t, intmax_t,
__MPFR_DECLSPEC int mpfr_set_uj_2exp (mpfr_ptr, uintmax_t, intmax_t,
However, for mpfr_sub_xx there are no sj and uj variants:
$ grep -P 'mpfr_sub_' mpfr.h
__MPFR_DECLSPEC int mpfr_sub_q (mpfr_ptr, mpfr_srcptr, mpq_srcptr, mpfr_rnd_t);
__MPFR_DECLSPEC int mpfr_sub_ui (mpfr_ptr, mpfr_srcptr, unsigned long,
__MPFR_DECLSPEC int mpfr_sub_si (mpfr_ptr, mpfr_srcptr, long, mpfr_rnd_t);
__MPFR_DECLSPEC int mpfr_sub_d (mpfr_ptr, mpfr_srcptr, double, mpfr_rnd_t);
__MPFR_DECLSPEC int mpfr_sub_z (mpfr_ptr, mpfr_srcptr, mpz_srcptr, mpfr_rnd_t);
Why? Will it be useful to have sj and uj variants for mpfr_sub_xx (and others)?
In the implementation, the
sivariants are very simple functions based on theuifunctions:src/si_op.c. So the first reason thesjvariants are not provided is because theujvariants are not provided.Now, the most basic
uivariants (likempfr_mul_uiandmpfr_add_ui) were added in 1999 and 2000, in the first year of the MPFR development. The firstintmax_tbased functions were added only in 2004 (mpfr_set_ones, andmpfr_get_ones a few months later). The initial goal was just to be able to do conversions, which is sufficient for most needs: by choosing an adequate precision, one can do an exact conversion to a MPFR number, then the wanted operation similar to theuiandsivariants. Additional variants could be added in the future, but this is not done yet.Note that the
TODOcurrently hasSuch functions would at least be useful internally. But other variants could be added too.