diff options
author | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2009-03-30 08:45:25 +0000 |
---|---|---|
committer | thevenyp <thevenyp@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2009-03-30 08:45:25 +0000 |
commit | 8e4020bd268c10edcfc637d299de45657a1c031e (patch) | |
tree | 5a02960a46fdfc2bde0e81c37404bced5a2abe5d /src/set_x.c | |
parent | 8e71becb13dc7ee4136846fb8f15e925eecf1145 (diff) | |
download | mpc-8e4020bd268c10edcfc637d299de45657a1c031e.tar.gz |
src/mpc.h src/set_x.c: New functions mpc_set_ui and mpc_set_sj.
tests/tset.c: Add tests for new functions mpc_set_ui and mpc_set_sj.
doc/mpc.texi NEWS: Add documentation for mpc_set_uj and mpc_set_sj.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@516 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'src/set_x.c')
-rw-r--r-- | src/set_x.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/set_x.c b/src/set_x.c index 5f20220..e20138a 100644 --- a/src/set_x.c +++ b/src/set_x.c @@ -20,6 +20,16 @@ along with the MPC Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "config.h" + +#if HAVE_INTTYPES_H +# include <inttypes.h> /* for intmax_t */ +#else +# if HAVE_STDINT_H +# include <stdint.h> +# endif +#endif + #include "mpc-impl.h" int @@ -109,3 +119,27 @@ mpc_set_f (mpc_ptr a, mpf_srcptr b, mpc_rnd_t rnd) return MPC_INEX(inex_re, inex_im); } + +#ifdef _MPC_H_HAVE_INTMAX_T +int +mpc_set_uj (mpc_ptr a, uintmax_t b, mpc_rnd_t rnd) +{ + int inex_re, inex_im; + + inex_re = mpfr_set_uj (MPC_RE (a), b, MPC_RND_RE (rnd)); + inex_im = mpfr_set_ui (MPC_IM (a), 0, GMP_RNDN); + + return MPC_INEX(inex_re, inex_im); +} + +int +mpc_set_sj (mpc_ptr a, intmax_t b, mpc_rnd_t rnd) +{ + int inex_re, inex_im; + + inex_re = mpfr_set_sj (MPC_RE (a), b, MPC_RND_RE (rnd)); + inex_im = mpfr_set_ui (MPC_IM (a), 0, GMP_RNDN); + + return MPC_INEX(inex_re, inex_im); +} +#endif |