diff options
author | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-03-15 14:09:49 +0000 |
---|---|---|
committer | pelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4> | 2004-03-15 14:09:49 +0000 |
commit | 6a5d19f819593d94aa5508b28cb63aa46650a651 (patch) | |
tree | 0702ba265b0a3e063da65ce74e80db5be64232e5 | |
parent | d711faa59b0459270b9042831fef6c048d5ff6d8 (diff) | |
download | mpfr-6a5d19f819593d94aa5508b28cb63aa46650a651.tar.gz |
Add new functions:
mpfr_set_sj_2exp, mpfr_set_sj
mpfr_set_uj_2exp, mpfr_set_uj
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2842 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | mpfr.h | 39 | ||||
-rw-r--r-- | set_sj.c | 58 | ||||
-rw-r--r-- | set_uj.c | 107 | ||||
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/tset_sj.c | 185 |
6 files changed, 389 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am index 6b2ca1686..fd5a3ed40 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,7 +7,7 @@ include_HEADERS = mpfr.h mpf2mpfr.h lib_LIBRARIES = libmpfr.a -libmpfr_a_SOURCES = mpfr.h mpf2mpfr.h mpfr-impl.h mpfr-test.h log_b2.h exceptions.c save_expo.c extract.c uceil_exp2.c uceil_log2.c ufloor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_si.c cmp_ui.c comparisons.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp10.c exp2.c exp3.c exp.c frac.c get_d.c get_exp.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c next.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c round_prec.c set.c setmax.c setmin.c set_d.c set_dfl_prec.c set_exp.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c get_z_exp.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c sin_cos.c set_nan.c set_inf.c powerof2.c gamma.c set_ld.c get_ld.c cbrt.c volatile.c fits_s.h fits_sshort.c fits_sint.c fits_slong.c fits_u.h fits_ushort.c fits_uint.c fits_ulong.c get_si.c get_ui.c zeta.c cmp_d.c erf.c inits.c inits2.c clears.c sgn.c check.c sub1sp.c version.c mpn_exp.c mpfr-gmp.c mp_clz_tab.c sum.c add1sp.c free_cache.c si_op.c cmp_ld.c set_ui_2exp.c set_si_2exp.c +libmpfr_a_SOURCES = mpfr.h mpf2mpfr.h mpfr-impl.h mpfr-test.h log_b2.h exceptions.c save_expo.c extract.c uceil_exp2.c uceil_log2.c ufloor_log2.c add.c add1.c add_one_ulp.c add_ui.c agm.c clear.c cmp.c cmp_abs.c cmp_si.c cmp_ui.c comparisons.c div_2exp.c div_2si.c div_2ui.c div.c div_ui.c dump.c eq.c exp10.c exp2.c exp3.c exp.c frac.c get_d.c get_exp.c get_str.c init.c inp_str.c isinteger.c isinf.c isnan.c isnum.c const_log2.c log.c mul_2exp.c mul_2si.c mul_2ui.c mul.c mul_ui.c neg.c next.c out_str.c const_pi.c pow.c pow_si.c pow_ui.c print_raw.c print_rnd_mode.c random2.c random.c reldiff.c round_prec.c set.c setmax.c setmin.c set_d.c set_dfl_prec.c set_exp.c set_rnd.c set_f.c set_prc_raw.c set_prec.c set_q.c set_si.c set_str.c set_str_raw.c set_ui.c set_z.c sqrt.c sqrt_ui.c sub.c sub1.c sub_one_ulp.c sub_ui.c rint.c ui_div.c ui_sub.c urandomb.c get_z_exp.c swap.c factorial.c cosh.c sinh.c tanh.c acosh.c asinh.c atanh.c atan.c cmp2.c exp_2.c asin.c const_euler.c cos.c sin.c tan.c fma.c hypot.c log1p.c expm1.c log2.c log10.c ui_pow.c ui_pow_ui.c minmax.c dim.c copysign.c gmp_op.c init2.c acos.c sin_cos.c set_nan.c set_inf.c powerof2.c gamma.c set_ld.c get_ld.c cbrt.c volatile.c fits_s.h fits_sshort.c fits_sint.c fits_slong.c fits_u.h fits_ushort.c fits_uint.c fits_ulong.c get_si.c get_ui.c zeta.c cmp_d.c erf.c inits.c inits2.c clears.c sgn.c check.c sub1sp.c version.c mpn_exp.c mpfr-gmp.c mp_clz_tab.c sum.c add1sp.c free_cache.c si_op.c cmp_ld.c set_ui_2exp.c set_si_2exp.c set_uj.c set_sj.c libmpfr_a_LIBADD = @LIBOBJS@ @@ -36,11 +36,35 @@ MA 02111-1307, USA. */ # include <gmp.h> #endif -/* Check if stdio.h is included or if the user wants to use FILE functions */ +/* Macros to detect STDC, GCC and GLIBC */ +#if defined(__STDC_VERSION__) +# define __MPFR_STDC(version) (__STDC_VERSION__>=(version)) +#elif defined(__STDC__) +# define __MPFR_STDC(version) (0 == (version)) +#else +# define __MPFR_STDC(version) 0 +#endif +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define __MPFR_GNUC(a, i) ((__GNUC__<<16)+__GNUC_MINOR__>=((a)<<16)+(i)) +#else +# define __MPFR_GNUC(a, i) 0 +#endif +#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) +# define __MPFR_GLIBC(a, i) ((__GLIBC__<<16)+__GLIBC_MINOR__>=((a)<<16)+(i)) +#else +# define __MPFR_GLIBC(a, i) 0 +#endif + +/* Check if stdio.h is included or if the user wants to use FILE */ #if defined (_GMP_H_HAVE_FILE) || defined (MPFR_USE_FILE) # define _MPFR_H_HAVE_FILE 1 #endif +/* Check if stdint.h is included or if the user wants to use intmax_t */ +#if (defined (INTMAX_C) && defined (UINTMAX_C)) || defined (MPFR_USE_INTMAX_T) +# define _MPFR_H_HAVE_INTMAX_T 1 +#endif + /* Definition of rounding modes (DON'T USE GMP_RNDNA!)*/ typedef enum { GMP_RNDN=0, GMP_RNDZ, GMP_RNDU, GMP_RNDD, GMP_RND_MAX, @@ -75,7 +99,7 @@ typedef unsigned long mpfr_prec_t; /* Definition of precision limits */ #define MPFR_PREC_MIN 2 -#define MPFR_PREC_MAX ((~(mpfr_prec_t)0) >> 1 ) +#define MPFR_PREC_MAX ((~(mpfr_prec_t)0)>>1) /* Definition of sign */ typedef int mpfr_sign_t; @@ -207,6 +231,17 @@ int mpfr_copysign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t)); int mpfr_neg _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t)); +#ifdef _MPFR_H_HAVE_INTMAX_T +#define mpfr_set_sj mpfr_set_sj_internal +#define mpfr_set_sj_2exp mpfr_set_sj_2exp_internal +#define mpfr_set_uj mpfr_set_uj_internal +#define mpfr_set_uj_2exp mpfr_set_uj_2exp_internal +int mpfr_set_sj _MPFR_PROTO ((mpfr_t, intmax_t, mpfr_rnd_t)); +int mpfr_set_sj_2exp _MPFR_PROTO ((mpfr_t, intmax_t, intmax_t, mpfr_rnd_t)); +int mpfr_set_uj _MPFR_PROTO ((mpfr_t, uintmax_t, mpfr_rnd_t)); +int mpfr_set_uj_2exp _MPFR_PROTO ((mpfr_t, uintmax_t, intmax_t, mpfr_rnd_t)); +#endif + mp_exp_t mpfr_get_z_exp _MPFR_PROTO ((mpz_ptr, mpfr_srcptr)); double mpfr_get_d _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t)); long double mpfr_get_ld _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t)); diff --git a/set_sj.c b/set_sj.c new file mode 100644 index 000000000..29eadbd07 --- /dev/null +++ b/set_sj.c @@ -0,0 +1,58 @@ +/* mpfr_set_sj -- set a MPFR number from a huge machine signed integer + +Copyright 2004 Free Software Foundation. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR 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. */ + +#if HAVE_CONFIG_H +# include "config.h" /* for a build within gmp */ +#endif + +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif + +#define MPFR_NEED_LONGLONG_H +#include "mpfr-impl.h" + +#ifdef _MPFR_H_HAVE_INTMAX_T + +int +mpfr_set_sj (mpfr_t x, intmax_t j, mp_rnd_t rnd) +{ + return mpfr_set_sj_2exp (x, j, 0, rnd); +} + +int +mpfr_set_sj_2exp (mpfr_t x, intmax_t j, intmax_t e, mp_rnd_t rnd) +{ + if (j>=0) + return mpfr_set_uj_2exp (x, j, e, rnd); + else + { + int inex; + inex = mpfr_set_uj_2exp (x, -j, e, MPFR_INVERT_RND (rnd) ); + MPFR_CHANGE_SIGN (x); + return -inex; + } +} + +#endif diff --git a/set_uj.c b/set_uj.c new file mode 100644 index 000000000..a8f413fd7 --- /dev/null +++ b/set_uj.c @@ -0,0 +1,107 @@ +/* mpfr_set_uj -- set a MPFR number from a huge machine unsigned integer + +Copyright 2004 Free Software Foundation. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR 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. */ + +#if HAVE_CONFIG_H +# include "config.h" /* for a build within gmp */ +#endif + +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif +#include <limits.h> /* For CHAR_BIT */ + +#define MPFR_NEED_LONGLONG_H +#include "mpfr-impl.h" + +#ifdef _MPFR_H_HAVE_INTMAX_T + +int +mpfr_set_uj (mpfr_t x, uintmax_t j, mp_rnd_t rnd) +{ + return mpfr_set_uj_2exp (x, j, 0, rnd); +} + +int +mpfr_set_uj_2exp (mpfr_t x, uintmax_t j, intmax_t e, mp_rnd_t rnd) +{ + unsigned int cnt, i; + mp_size_t k, len; + mp_limb_t limb; + mp_limb_t yp[sizeof(uintmax_t)/sizeof(mp_limb_t)]; + mpfr_t y; + + /* Special case */ + if (j == 0) + { + MPFR_SET_POS(x); + MPFR_SET_ZERO(x); + MPFR_RET(0); + } + + /* Create an auxillary var */ + MPFR_TMP_INIT1 (yp, y, sizeof(uintmax_t)*CHAR_BIT); + for (i = 0 ; i < numberof (yp) ; i++, j>>=BITS_PER_MP_LIMB) + yp[i] = j; /* Only the low bits are copied */ + + /* Find the first limb not equal to zero. */ + k = numberof (yp); + do { + MPFR_ASSERTD( k > 0 ); + limb = yp[--k]; + } while (limb == 0); + count_leading_zeros(cnt, limb); + k++; + len = numberof (yp) - k; + + /* Normalize it: len = number of last 0 limb, k number of non-zero limbs */ + if (MPFR_LIKELY(cnt)) + mpn_lshift (yp+len, yp, k, cnt); /* Normalize the High Limb*/ + else if (len != 0) + MPN_COPY_DECR (yp+len, yp, k); /* Must use DECR */ + MPN_ZERO (yp, len); /* Zeroing the last limbs */ + e = e + k*BITS_PER_MP_LIMB - cnt; /* Update Expo */ + MPFR_ASSERTD (MPFR_LIMB_MSB(yp[numberof(yp)-1]) != 0); + + /* Check expo underflow / overflow (can't use mpfr_check_range) */ + if (MPFR_UNLIKELY(e < __gmpfr_emin)) + { + /* The following test is necessary because in the rounding to the + * nearest mode, mpfr_set_underflow always rounds away from 0. In + * this rounding mode, we need to round to 0 if: + * _ |x| < 2^(emin-2), or + * _ |x| = 2^(emin-2) and the absolute value of the exact + * result is <= 2^(emin-2). */ + if (rnd == GMP_RNDN && (e+1 < __gmpfr_emin || mpfr_powerof2_raw(y))) + rnd = GMP_RNDZ; + return mpfr_set_underflow (x, rnd, MPFR_SIGN_POS); + } + if (MPFR_UNLIKELY(e > __gmpfr_emax)) + return mpfr_set_overflow (x, rnd, MPFR_SIGN_POS); + MPFR_SET_EXP (y, e); + + /* Final: set x to y (rounding if necessary) */ + return mpfr_set (x, y, rnd); +} + +#endif diff --git a/tests/Makefile.am b/tests/Makefile.am index 647bdd22f..7f29accb3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = gnu -check_PROGRAMS = tversion tinits tsgn tcheck tisnan texceptions tset tabs tset_d tset_f tset_q tset_si tset_str tset_z tset_ld tadd tsub tmul tdiv tcmp tcmp2 tcmpabs tcan_round tround_prec tswap reuse tsqrt tnext tcomparisons teq tadd_ui tsub_ui tcmp_ui tdiv_ui tmul_ui tsqrt_ui tui_div tui_sub tcmp_d tmul_2exp tfma tfrac tget_str tout_str tget_d tget_d_2exp tconst_log2 tconst_pi tconst_euler trandom ttrunc trint texp texp2 texpm1 tlog tlog2 tlog10 tlog1p tpow tui_pow tpow3 tcosh tsinh ttanh tacosh tasinh tatanh thyperbolic tasin tacos tcos tatan tsin ttan tsin_cos tagm thypot tfactorial tgamma terf tcbrt mpf_compat mpfr_compat tzeta tsub1sp tadd1sp tgmpop tsum tdim tminmax tcopysign toutimpl tfits tinp_str tset_exp tsi_op tcmp_ld +check_PROGRAMS = tversion tinits tsgn tcheck tisnan texceptions tset tabs tset_d tset_f tset_q tset_si tset_str tset_z tset_ld tadd tsub tmul tdiv tcmp tcmp2 tcmpabs tcan_round tround_prec tswap reuse tsqrt tnext tcomparisons teq tadd_ui tsub_ui tcmp_ui tdiv_ui tmul_ui tsqrt_ui tui_div tui_sub tcmp_d tmul_2exp tfma tfrac tget_str tout_str tget_d tget_d_2exp tconst_log2 tconst_pi tconst_euler trandom ttrunc trint texp texp2 texpm1 tlog tlog2 tlog10 tlog1p tpow tui_pow tpow3 tcosh tsinh ttanh tacosh tasinh tatanh thyperbolic tasin tacos tcos tatan tsin ttan tsin_cos tagm thypot tfactorial tgamma terf tcbrt mpf_compat mpfr_compat tzeta tsub1sp tadd1sp tgmpop tsum tdim tminmax tcopysign toutimpl tfits tinp_str tset_exp tsi_op tcmp_ld tset_sj EXTRA_DIST = tgeneric.c mpf_compat.h inp_str.data diff --git a/tests/tset_sj.c b/tests/tset_sj.c new file mode 100644 index 000000000..4f75f2bcd --- /dev/null +++ b/tests/tset_sj.c @@ -0,0 +1,185 @@ +/* Test file for + mpfr_set_sj, mpfr_set_uj, mpfr_set_sj_2exp and mpfr_set_uj_2exp. + +Copyright 2004 Free Software Foundation, Inc. + +This file is part of the MPFR Library. + +The MPFR Library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at your +option) any later version. + +The MPFR Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the MPFR 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. */ + +#if HAVE_CONFIG_H +# include "config.h" /* for a build within gmp */ +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <limits.h> + +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif + +#include "mpfr-test.h" + +#ifndef _MPFR_H_HAVE_INTMAX_T +int main() { return 0; } +#else + +#define ERROR(str) {printf("Error for "str"\n"); exit(1);} + +static void +check_set_uj (mp_prec_t pmin, mp_prec_t pmax, int N) +{ + mpfr_t x, y; + mp_prec_t p; + int inex1, inex2, n; + mp_limb_t limb; + + mpfr_inits2 (pmax, x, y, NULL); + + for ( p = pmin ; p < pmax ; p++) + { + mpfr_set_prec (x, p); + mpfr_set_prec (y, p); + for (n = 0 ; n < N ; n++) + { + /* mp_limb_t may be unsigned long long */ + limb = (unsigned long) randlimb (); + inex1 = mpfr_set_uj (x, limb, GMP_RNDN); + inex2 = mpfr_set_ui (y, limb, GMP_RNDN); + if (mpfr_cmp (x, y)) + { + printf ("ERROR for mpfr_set_uj and j=%lu and p=%lu\n", + (unsigned long) limb, p); + printf ("X="); mpfr_dump (x); + printf ("Y="); mpfr_dump (y); + exit (1); + } + if (inex1 != inex2) + { + printf ("ERROR for inexact(set_uj): j=%lu p=%lu\n" + "Inexact1= %d Inexact2= %d\n", + (unsigned long) limb, p, inex1, inex2); + exit (1); + } + } + } + /* Special case */ + mpfr_set_prec (x, sizeof(uintmax_t)*CHAR_BIT); + inex1 = mpfr_set_uj (x, UINTMAX_MAX, GMP_RNDN); + if (inex1 != 0 || mpfr_sgn(x) <= 0) + ERROR ("inexact / UINTMAX_MAX"); + inex1 = mpfr_add_ui (x, x, 1, GMP_RNDN); + if (inex1 != 0 || !mpfr_powerof2_raw (x) + || MPFR_EXP (x) != (sizeof(uintmax_t)*CHAR_BIT+1) ) + ERROR ("power of 2"); + + mpfr_clears (x, y, NULL); +} + +static void +check_set_uj_2exp (void) +{ + mpfr_t x; + int inex; + + mpfr_init2 (x, sizeof(uintmax_t)*CHAR_BIT); + + inex = mpfr_set_uj_2exp (x, 1, 0, GMP_RNDN); + if (inex || mpfr_cmp_ui(x, 1)) + ERROR("(1U,0)"); + + inex = mpfr_set_uj_2exp (x, 1024, -10, GMP_RNDN); + if (inex || mpfr_cmp_ui(x, 1)) + ERROR("(1024U,-10)"); + + inex = mpfr_set_uj_2exp (x, 1024, 10, GMP_RNDN); + if (inex || mpfr_cmp_ui(x, 1024*1024)) + ERROR("(1024U,+10)"); + + inex = mpfr_set_uj_2exp (x, UINTMAX_MAX, 1000, GMP_RNDN); + inex |= mpfr_div_2ui (x, x, 1000, GMP_RNDN); + inex |= mpfr_add_ui (x, x, 1, GMP_RNDN); + if (inex || !mpfr_powerof2_raw (x) + || MPFR_EXP (x) != (sizeof(uintmax_t)*CHAR_BIT+1) ) + ERROR("(UINTMAX_MAX)"); + + inex = mpfr_set_uj_2exp (x, UINTMAX_MAX, MPFR_EMAX_MAX-10, GMP_RNDN); + if (inex == 0 || !mpfr_inf_p (x)) + ERROR ("Overflow"); + + inex = mpfr_set_uj_2exp (x, UINTMAX_MAX, MPFR_EMIN_MIN-1000, GMP_RNDN); + if (inex == 0 || !MPFR_IS_ZERO (x)) + ERROR ("Underflow"); + + mpfr_clear (x); +} + +static void +check_set_sj () +{ + mpfr_t x; + int inex; + + mpfr_init2 (x, sizeof(intmax_t)*CHAR_BIT-1); + + inex = mpfr_set_sj (x, -INTMAX_MAX, GMP_RNDN); + inex |= mpfr_add_si (x, x, -1, GMP_RNDN); + if (inex || mpfr_sgn (x) >=0 || !mpfr_powerof2_raw (x) + || MPFR_EXP (x) != (sizeof(intmax_t)*CHAR_BIT) ) + ERROR("set_sj (-INTMAX_MAX)"); + + inex = mpfr_set_sj (x, 1742, GMP_RNDN); + if (inex || mpfr_cmp_ui (x, 1742)) + ERROR ("set_sj (1742)"); + + mpfr_clear (x); +} + +static void +check_set_sj_2exp () +{ + mpfr_t x; + int inex; + + mpfr_init2 (x, sizeof(intmax_t)*CHAR_BIT-1); + + inex = mpfr_set_sj_2exp (x, INTMAX_MIN, 1000, GMP_RNDN); + if (inex || mpfr_sgn (x) >=0 || !mpfr_powerof2_raw (x) + || MPFR_EXP (x) != (sizeof(intmax_t)*CHAR_BIT+1000) ) + ERROR("set_sj_2exp (INTMAX_MIN)"); + + mpfr_clear (x); +} + +int +main (int argc, char *argv[]) +{ + tests_start_mpfr (); + + check_set_uj (2, 128, 50); + check_set_uj_2exp (); + check_set_sj (); + check_set_sj_2exp (); + + tests_end_mpfr (); + return 0; +} + +#endif |