summaryrefslogtreecommitdiff
path: root/set_ui.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2001-11-10 01:45:36 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2001-11-10 01:45:36 +0000
commitf1c41fb6bd97c0a5680aa4df1a00a01f4a4d0d60 (patch)
tree08e27e3c47d4584830acca621cbe6364d1386d37 /set_ui.c
parent3bdb8b4f6f3ab6fc0c2aa5f71535a2c7133cc04c (diff)
downloadmpfr-f1c41fb6bd97c0a5680aa4df1a00a01f4a4d0d60.tar.gz
GNU coding style. K&R function headers removed.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1488 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'set_ui.c')
-rw-r--r--set_ui.c78
1 files changed, 36 insertions, 42 deletions
diff --git a/set_ui.c b/set_ui.c
index e3e0d3432..3d98c3aba 100644
--- a/set_ui.c
+++ b/set_ui.c
@@ -26,14 +26,7 @@ MA 02111-1307, USA. */
#include "mpfr-impl.h"
int
-#if __STDC__
mpfr_set_ui (mpfr_ptr x, unsigned long i, mp_rnd_t rnd_mode)
-#else
-mpfr_set_ui (x, i, rnd_mode)
- mpfr_ptr x;
- unsigned long i;
- mp_rnd_t rnd_mode;
-#endif
{
int inex = 0;
@@ -41,45 +34,46 @@ mpfr_set_ui (x, i, rnd_mode)
if (i == 0)
MPFR_SET_ZERO(x); /* the sign will be set later */
else
- {
- mp_size_t xn;
- unsigned int cnt, nbits;
- mp_limb_t *xp;
-
- xn = (MPFR_PREC(x)-1)/BITS_PER_MP_LIMB;
- count_leading_zeros(cnt, (mp_limb_t) i);
-
- xp = MPFR_MANT(x);
- xp[xn] = ((mp_limb_t) i) << cnt;
- /* don't forget to put zero in lower limbs */
- MPN_ZERO(xp, xn);
-
- MPFR_EXP(x) = nbits = BITS_PER_MP_LIMB - cnt;
- inex = mpfr_check_range(x, rnd_mode);
- if (inex)
- return inex; /* underflow or overflow */
-
- /* round if MPFR_PREC(x) smaller than length of i */
- if (MPFR_PREC(x) < nbits)
{
- int carry;
- carry = mpfr_round_raw(xp+xn, xp+xn, nbits, 0, MPFR_PREC(x),
- rnd_mode, &inex);
- if (carry)
- {
- mp_exp_t exp = MPFR_EXP(x);
-
- if (exp == __mpfr_emax)
- return mpfr_set_overflow(x, rnd_mode, 1);
-
- MPFR_EXP(x)++;
- xp[xn] = MP_LIMB_T_HIGHBIT;
- }
+ mp_size_t xn;
+ unsigned int cnt, nbits;
+ mp_limb_t *xp;
+
+ xn = (MPFR_PREC(x)-1)/BITS_PER_MP_LIMB;
+ count_leading_zeros(cnt, (mp_limb_t) i);
+
+ xp = MPFR_MANT(x);
+ xp[xn] = ((mp_limb_t) i) << cnt;
+ /* don't forget to put zero in lower limbs */
+ MPN_ZERO(xp, xn);
+
+ MPFR_EXP(x) = nbits = BITS_PER_MP_LIMB - cnt;
+ inex = mpfr_check_range(x, rnd_mode);
+ if (inex)
+ return inex; /* underflow or overflow */
+
+ /* round if MPFR_PREC(x) smaller than length of i */
+ if (MPFR_PREC(x) < nbits)
+ {
+ int carry;
+ carry = mpfr_round_raw(xp+xn, xp+xn, nbits, 0, MPFR_PREC(x),
+ rnd_mode, &inex);
+ if (carry)
+ {
+ mp_exp_t exp = MPFR_EXP(x);
+
+ if (exp == __mpfr_emax)
+ return mpfr_set_overflow(x, rnd_mode, 1);
+
+ MPFR_EXP(x)++;
+ xp[xn] = MP_LIMB_T_HIGHBIT;
+ }
+ }
}
- }
/* warning: don't change the precision of x! */
- if (MPFR_SIGN(x) < 0) MPFR_CHANGE_SIGN(x);
+ if (MPFR_SIGN(x) < 0)
+ MPFR_CHANGE_SIGN(x);
MPFR_RET(inex);
}